8354894: java/lang/Thread/virtual/Starvation.java timeout on server with high CPUs

Co-authored-by: Alan Bateman <alanb@openjdk.org>
Reviewed-by: jpai
This commit is contained in:
SendaoYan 2025-10-01 00:52:30 +00:00
parent 9b02896b47
commit 0366d8823b

View File

@ -25,7 +25,7 @@
* @requires vm.continuations
* @library /test/lib
* @bug 8345294
* @run main/othervm/timeout=800/native --enable-native-access=ALL-UNNAMED Starvation 100000
* @run main/othervm/native --enable-native-access=ALL-UNNAMED Starvation
*/
import java.time.Duration;
@ -37,9 +37,16 @@ import jdk.test.lib.thread.VThreadPinner;
public class Starvation {
public static void main(String[] args) throws Exception {
int iterations = Integer.parseInt(args[0]);
int iterations;
if (args.length > 0) {
iterations = Integer.parseInt(args[0]);
} else {
int nprocs = Runtime.getRuntime().availableProcessors();
iterations = 40_000 / nprocs;
}
for (int i = 0; i < iterations; i++) {
for (int i = 1; i <= iterations; i++) {
System.out.format("%s iteration %d of %d ...%n", Instant.now(), i, iterations);
var exRef = new AtomicReference<Exception>();
Thread thread = Thread.startVirtualThread(() -> {
try {