graceful thread termination with pthread_cond_signal proving problematic
问题 I need to fire of a bunch of threads and would like to bring them down gracefully. I'm trying to use pthread_cond_signal / pthread_cond_wait to achieve this but am running into a problem. Here's my code. firstly the thread_main static void *thrmain( void * arg ) { // acquire references to the cond var, mutex, finished flag and // message queue ..... while( true ) { pthread_mutex_lock( &lock ); if ( msq.empty() ) { // no messages so wait for one. pthread_cond_wait( &cnd, &lock ); } // are we