随笔分类 - linux\c++
摘要:pthread_cond_wai(条件等待)通常情况下,pthread_cond_wait() 和mutex一起配合使用。用生产者与消费者的关系来看。例如,有一个生产者,2个消费者。 1 //定义全局的 互斥对象和条件等待对象 2 3 pthread_mutex_t mtx; 4 5 pthread_cond_t cond; 6 7 //消费者线程函数: 8 9 void threadproc(void * parm)10 11 {12 13 while(1)14 15 {16 17 pthread_mutex_lock(&mtx);//锁定mtx ,以...
阅读全文
浙公网安备 33010602011771号