Does “pthread_mutex_t mutex = {0}” initialize mutex?
问题 Is it possible to initialize mutex in this way: pthread_mutex_t mutex = {0}; What is the difference between the following 3 initialization of mutex: 1) pthread_mutex_init(&mutex, NULL); 2) pthread_mutex_t mutex = {0}; 3) pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 回答1: With the first option, you control the time at which the mutex is initialized (also: the argument should be &mutex ) by calling the initializer function explicitly. The second option is assuming things about the internal