/*支持递归加锁*/
pthread_mutex_t mutex_x;
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE_NP);
pthread_mutex_init(&mutex_x,&attr);
pthread_mutex_lock(&mutex_x);
pthread_mutex_lock(&mutex_x);
//CODE
pthread_mutex_unlock(&mutex_x);
pthread_mutex_unlock(&mutex_x);
参考
阅读(1068) | 评论(0) | 转发(0) |