pthread_mutex_destroy 信号量将阻塞!

#include<stdio.h>
  2 #include<stdlib.h>
  3 #include <pthread.h>
  4 pthread_mutex_t command_mutex_ = PTHREAD_MUTEX_INITIALIZER;
  5 pthread_cond_t command_cond_ = PTHREAD_COND_INITIALIZER;
  6 int main(){
  7
  8    pthread_mutex_destroy(&command_mutex_);
  9  printf("--------0000\n");
10    pthread_cond_destroy(&command_cond_);
11  printf("--------1111\n");
12    pthread_mutex_lock(&command_mutex_);
13  printf("--------222\n");
14 // stop        pthread_cond_signal(&command_cond_);在此阻塞
15 // stop        pthread_cond_wait(&command_mutex_,&command_cond_);在此阻塞
16  printf("--------333\n");
17           pthread_mutex_unlock(&command_mutex_);
18
19  printf("--------4444\n");
20  printf("over\n");
21
22 }

你可能感兴趣的:(c)