- 創(chuàng)建線程
pthread_create
- 啟動(dòng)線程
pthread_join
- 線程鎖
//互斥鎖
pthread_mutex_t mutex;
//條件變量
pthread_cond_t has_product;
pthread_mutex_lock(&mutex);
...
pthread_cond_signal(&has_product);
pthread_cond_broadcast(&player->cond);
pthread_cond_timeout_np(&player->cond,&player->mutex, sleep_time/1000ll);
...
pthread_mutex_unlock(&mutex);
//銷毀互斥鎖和條件變量
pthread_mutex_destroy(&mutex);
pthread_cond_destroy(&has_product);