Skip to content

Commit

Permalink
8316924: java/lang/Thread/virtual/stress/ParkALot.java times out
Browse files Browse the repository at this point in the history
Reviewed-by: jpai
  • Loading branch information
Alan Bateman committed Sep 27, 2023
1 parent ad6df41 commit b24ad7c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/jdk/java/lang/Thread/virtual/stress/ParkALot.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/*
* @test
* @requires vm.debug == true
* @run main/othervm ParkALot 200000
* @run main/othervm ParkALot 100000
*/

import java.time.Instant;
Expand All @@ -50,15 +50,16 @@ public static void main(String[] args) {
iterations = ITERATIONS;
}

int maxThreads = Math.max(Runtime.getRuntime().availableProcessors() / 2, 1);
int maxThreads = Math.clamp(Runtime.getRuntime().availableProcessors() / 2, 1, 4);
for (int nthreads = 1; nthreads <= maxThreads; nthreads++) {
System.out.format("%s %d threads ...%n", Instant.now(), nthreads);
System.out.format("%s %d thread(s) ...%n", Instant.now(), nthreads);
ThreadFactory factory = Thread.ofPlatform().factory();
try (var executor = Executors.newThreadPerTaskExecutor(factory)) {
for (int i = 0; i < nthreads; i++) {
executor.submit(() -> parkALot(iterations));
}
}
System.out.format("%s %d thread(s) done%n", Instant.now(), nthreads);
}
}

Expand Down Expand Up @@ -87,7 +88,7 @@ private static void parkALot(int iterations) {
if (state == Thread.State.WAITING || state == Thread.State.TIMED_WAITING) {
LockSupport.unpark(vthread);
} else {
Thread.onSpinWait();
Thread.yield();
}
}
}
Expand Down

1 comment on commit b24ad7c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.