diff --git a/test/hotspot/jtreg/serviceability/jvmti/events/NotifyFramePopStressTest/NotifyFramePopStressTest.java b/test/hotspot/jtreg/serviceability/jvmti/events/NotifyFramePopStressTest/NotifyFramePopStressTest.java index 9840c9d6367..8240d943cd4 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/events/NotifyFramePopStressTest/NotifyFramePopStressTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/events/NotifyFramePopStressTest/NotifyFramePopStressTest.java @@ -78,6 +78,13 @@ public class NotifyFramePopStressTest { 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);