On 10/3/10, Robert Klemme <shortcutter / googlemail.com> wrote:
> On 03.10.2010 02:38, Caleb Clausen wrote:
>> But even then, there is a race
>> condition; you're not guaranteed that all the threads have blocked
>> waiting on the condvar. Some may still be running the code before that
>> point, and they would end up never running to completion.
>
> This is not true.  The only negative thing that would happen is that
> they would not start doing their work at the "same" time as the other
> threads.  Other than that they would do their work as the other threads.

Oh, you are right. The boolean variable start prevents the case I was
worried about. This is why I find condvars confusing.

>>> You can probably get away without the condition variable by just
>>> acquiring the lock (lock.synchronize) in the main thread before you
>>> create all threads and let all threads just synchronize with an empty
>>> block.
>>
>> I can't see any holes in this scheme, so it's probably the best idea.
>
> Even then it could be that some threads execute code before the
> synchronize and thus not start concurrently with other threads.

But you made the synchronize statement at the very start of the thread
body, so this would seem to not be a concern in this case.