深入理解pthread_cond_wait、pthread_cond_signal
转自:http://blog.csdn.net/yeyuangen/article/details/37593533 ===============================man pthread_cond_wait的解释========================== LINUX环境下多线程编程肯定会遇到需要条件变量的情况,此时必然要使用pthread_cond_wait()函数。但这个函数的执行过程比较难于理解。 pthread_cond_wait()的工作流程如下(以MAN中的EXAMPLE为例): Consider two shared variables x and y, protected by the mutex mut, and a condition vari- able cond that is to be signaled whenever x becomes greater than y. int x,y; pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t cond = PTHREAD_COND_INITIALIZER; Waiting until x is greater than y is performed as follows: pthread_mutex