
8 Dec
2008
8 Dec
'08
4:06 p.m.
void thread1(){ boost::mutex::scoped_lock lock(mutex);
...//do some work data_ready=true; cond.notify_one() //assume the condition is satisfied. //do more work -------my question is will this part continue? or thread2 will wake up and block thread 1?
}
The thread1() will continue and the thread2() will be still locked. If you wish to avoid this situation, you have to unlock the mutex manually before the notification: lock.unlock(); cond.notify_one(); ...as explained here: http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-...