
10 Dec
2009
10 Dec
'09
6:25 p.m.
Why is it that since we already hold a mutex in the requesting thread, the thread handling the response can successfully lock that mutex too? Does the condition.wait call set something in the lock?
Thanks,
Alessandro The idea of wait on a condition variable is to atomically release the mutex and enter some sort of sleep mode, which is later interrupted by a wake-up from a different thread. At that point the mutex is re-aquired. So, yes, condition.wait() unlocks the mutex and waits for notification, then locks the mutex again. -- Nikolai