|
Boost Users : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-04-19 15:01:25
PJ Durai wrote:
> On 4/18/07, Ken <krovchuck_at_[hidden]> wrote:
>>
>> On Apr 13, 2007, PJ Durai wrote:
>>>
>>
>>> I have two threads waiting on a condition. When I call
>>> condition::notify_all() from the main thread, I expected both
>>> threads to fall through and proceed simultaneously.
>>>
>>> But that is not what I am witnessing.
>>> They behave like I had called condition::notify_one() twice.
>>>
>>> One thread continues, does its thing (in this case a simple Sleep
>>> and a printf) comes back to wait. Only after that point the second
>>> thread continued from the condition.
>>>
>>> Is this expected ? What am I missing ?
This is expected. condition::wait reacquires the mutex after it returns. You
then call Sleep(4000) with the mutex locked; the other threads can't
continue because they are waiting for the mutex. Try unlocking lk before
Sleep'ing.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net