Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Condition.broadcast may not wake up all threads in native Windows build #5013
Original bug ID: 5013
If two threads are waiting on a condition, Condition.broadcast should wake both of them up. However, if the first thread to be awoken waits on the same condition again it may be woken up again instead of the other thread.
I marked reproducibility as random since it depends on threads, but it happens about 50% of the time.
Linux and bytecode-Windows seem to be immune from this problem.
The attached code can display the problem. Each line of the output begins with the thread which is printing it. two threads "t1" and "t2" wait on condition "c". The main thread then broadcasts the condition, which SHOULD wake up both threads eventually. On Linux this program always outputs:
indicating that both threads woke up. On Windows the program may return:
which is also correct (the threads were woken up in the opposite order as on Linux, but that doesn't matter). However Windows may also return the following: