现在的位置: 首页 > 综合 > 正文

linux进程线程通讯

2013年10月28日 ⁄ 综合 ⁄ 共 193字 ⁄ 字号 评论关闭

1. 互斥量

pthread_mutex_t mutex;

pthread_mutex_init(&mutex,NULL); // 创建互斥量

pthread_mutex_destory(&mutex);  // 销毁互斥量

pthread_mutex_lock(&mutex);// 使用并锁定互斥量,若已被锁定则睡眠等待

pthread_mutex_unlock(&mutex); // 使用完互斥量,则解锁

 

抱歉!评论已关闭.