Skip to content

Commit

Permalink
Fix deadlock during join()
Browse files Browse the repository at this point in the history
  • Loading branch information
plummercj committed Oct 22, 2024
1 parent 28147da commit a7ac005
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ private static void control(Thread thread) {
log("control has started");
while (!done) {
suspend(thread);
if (done) {
// Double check after suspending the thread. We don't want to do the notify
// if the main thread thinks it is done. An untimely notify during the
// join() call will result in a deadlock.
resume(thread);
break;
}
if (notifyFramePop(thread)) {
notifyCount++;
log("control incremented notifyCount to " + notifyCount);
Expand Down

0 comments on commit a7ac005

Please sign in to comment.