pthread_mutex_t _lock; //定义

pthread_mutex_init(&_lock, NULL); //初始化

pthread_mutex_lock(&_lock); // 上锁

pthread_mutex_unlock(&_lock); //解锁

这有个例子:TPMemoryCache

TAG:线程锁, pthread_mutex_t