Skip to content

Latest commit

 

History

History
11 lines (9 loc) · 419 Bytes

shi-yong-dao-de-ku-han-shu.md

File metadata and controls

11 lines (9 loc) · 419 Bytes

使用到的库函数

pthread_mutex_t lock;            // declare a lock
pthread_mutex_init(&lock, NULL); // initialize the lock
pthread_mutex_lock(&lock);       // acquire lock
pthread_mutex_unlock(&lock);     // release lock

pthread_cond_wait(&cond, &mutex);  // go to sleep on cond, releasing lock mutex, acquiring upon wake up
pthread_cond_broadcast(&cond);     // wake up every thread sleeping on cond