Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions test/jdk/java/lang/Thread/virtual/Starvation.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @requires vm.continuations
* @library /test/lib
* @bug 8345294
* @run main/othervm/timeout=200/native --enable-native-access=ALL-UNNAMED Starvation 100000
* @run main/othervm/native --enable-native-access=ALL-UNNAMED Starvation
*/

import java.time.Duration;
Expand All @@ -37,9 +37,16 @@

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 {
Expand Down