Skip to content

Commit adc3f53

Browse files
author
SendaoYan
committed
8349787: java/lang/Thread/virtual/ThreadPollOnYield.java#default passes unexpectedly without libVThreadPinner.so
Reviewed-by: alanb
1 parent 55097dd commit adc3f53

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/jdk/java/lang/Thread/virtual/ThreadPollOnYield.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@
4141
*/
4242

4343
import java.util.concurrent.atomic.AtomicBoolean;
44+
import java.util.concurrent.CountDownLatch;
4445

4546
import jdk.test.lib.thread.VThreadPinner;
4647
import org.junit.jupiter.api.Test;
4748
import static org.junit.jupiter.api.Assertions.*;
4849

4950
class ThreadPollOnYield {
51+
private static final CountDownLatch started = new CountDownLatch(1);
5052
static void foo(AtomicBoolean done) {
53+
started.countDown();
5154
while (!done.get()) {
5255
Thread.yield();
5356
}
@@ -59,7 +62,7 @@ void testThreadYieldPolls() throws Exception {
5962
var vthread = Thread.ofVirtual().start(() -> {
6063
VThreadPinner.runPinned(() -> foo(done));
6164
});
62-
Thread.sleep(5000);
65+
started.await();
6366
done.set(true);
6467
vthread.join();
6568

0 commit comments

Comments
 (0)