[Thread] How to wait for a thread until it stopped
Hi there, I'm still working on the transistion from an old thread lib to the boost thread lib. I have two threads, the GUI thread and a worker thread. The worker thread is always inside a loop that only breaks if someone set the flag. The GUI thread has from time to time to stop the worker thread. This is currently done by setting a flag ( _bStop ) and the worker thread will eventually stop like: void run() { boost::mutex::scoped_lock oLock( _oRunMutex ); do { ... if( _bStop ) _oRunCondition.wait( oLock ); } while( _bTerminate == false ); } I believe that this implemention can lead to deadlocks. But how can I implement the behavior that the GUI thread will break until the worker thread has stopped. Thanks, Christian
participants (1)
-
Christian Henning