Skip to content

Commit

Permalink
add /native for test/jdk/java/lang/Thread/virtual/ThreadPollOnYield.j…
Browse files Browse the repository at this point in the history
…ava test/jdk/java/lang/Thread/virtual/Starvation.java
  • Loading branch information
sendaoYan committed Feb 11, 2025
1 parent 7c03099 commit 413ee6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions test/jdk/java/lang/Thread/virtual/Starvation.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -25,7 +25,7 @@
* @requires vm.continuations
* @library /test/lib
* @bug 8345294
* @run main/othervm --enable-native-access=ALL-UNNAMED Starvation 100000
* @run main/othervm/timeout=200/native --enable-native-access=ALL-UNNAMED Starvation 100000
*/

import java.time.Duration;
Expand Down
11 changes: 8 additions & 3 deletions test/jdk/java/lang/Thread/virtual/ThreadPollOnYield.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -27,7 +27,7 @@
* @summary Test that Thread.yield loop polls for safepoints
* @requires vm.continuations
* @library /test/lib
* @run junit/othervm ThreadPollOnYield
* @run junit/othervm/native --enable-native-access=ALL-UNNAMED ThreadPollOnYield
*/

/*
Expand All @@ -36,7 +36,7 @@
* @summary Test that Thread.yield loop polls for safepoints
* @requires vm.continuations & vm.compMode != "Xcomp"
* @library /test/lib
* @run junit/othervm -Xcomp -XX:-TieredCompilation -XX:CompileCommand=inline,*::yield* -XX:CompileCommand=inline,*::*Yield ThreadPollOnYield
* @run junit/othervm/native --enable-native-access=ALL-UNNAMED -Xcomp -XX:-TieredCompilation -XX:CompileCommand=inline,*::yield* -XX:CompileCommand=inline,*::*Yield ThreadPollOnYield
*/

import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -46,8 +46,10 @@
import static org.junit.jupiter.api.Assertions.*;

class ThreadPollOnYield {
public static volatile boolean flag = false;
static void foo(AtomicBoolean done) {
while (!done.get()) {
flag = true;
Thread.yield();
}
}
Expand All @@ -62,6 +64,9 @@ void testThreadYieldPolls() throws Exception {
done.set(true);
vthread.join();

if (flag != true) {
throw new RuntimeException("flag = " + flag);
}
System.out.println("First vthread done");

AtomicBoolean done2 = new AtomicBoolean();
Expand Down

0 comments on commit 413ee6b

Please sign in to comment.