learn pthread_mutex, pthread_rwlock and pthread_cond, then implement producer_consumer with pthread_cond