diff --git a/test/hotspot/jtreg/serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java b/test/hotspot/jtreg/serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java index 62dfd6f8a79bb..2e3925a5ca7b7 100644 --- a/test/hotspot/jtreg/serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java +++ b/test/hotspot/jtreg/serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,8 @@ public class UnmountedVThreadNativeMethodAtTop { + boolean done; + /** * Test dumping the heap while a virtual thread is blocked entering a synchronized native method. */ @@ -96,7 +98,9 @@ void VThreadBlockedAtOjectWait() throws Exception { started.countDown(); try { synchronized (lock) { - lock.wait(); + while (!done) { + lock.wait(); + } } } catch (InterruptedException e) { } }); @@ -109,11 +113,11 @@ void VThreadBlockedAtOjectWait() throws Exception { Path dumpFile = dumpHeap(); verifyHeapDump(dumpFile); - + } finally { synchronized (lock) { + done = true; lock.notify(); } - } finally { vthread.join(); } } @@ -159,4 +163,4 @@ private void await(Thread thread, Thread.State expectedState) throws Interrupted static { System.loadLibrary("UnmountedVThreadNativeMethodAtTop"); } -} \ No newline at end of file +}