The microbenchmark "test/micro/org/openjdk/bench/java/lang/ThreadOnSpinWaitProducerConsumer.java" runs with a producer and a consumer thread interacting with one another through two shared variables.
When the benchmark run has complete, the producer thread exists once a counter exceeds a given number. The consumer thread exits after it has been interrupted. The thread executing the trial method that coordinates this called "Thread.join" on the producer thread before calling "Thread.interrupt" on the consumer thread and then exiting.
The harness will create new producer and consumer threads. However, the consumer thread may still be executing as the "trial" method doesn't wait for the consumer thread to exit. This can consume values from the producer and exit, leaving the other consumer thread waiting indefinitely.
My suggested solution is for the "trial" method to call "Thread.join" against the consumer thread. This prevents the test from restarting with two active consumer threads.
This happens on x86 and aarch64 Linux. With the correct timing, I expect any platform would be affected.
When the benchmark run has complete, the producer thread exists once a counter exceeds a given number. The consumer thread exits after it has been interrupted. The thread executing the trial method that coordinates this called "Thread.join" on the producer thread before calling "Thread.interrupt" on the consumer thread and then exiting.
The harness will create new producer and consumer threads. However, the consumer thread may still be executing as the "trial" method doesn't wait for the consumer thread to exit. This can consume values from the producer and exit, leaving the other consumer thread waiting indefinitely.
My suggested solution is for the "trial" method to call "Thread.join" against the consumer thread. This prevents the test from restarting with two active consumer threads.
This happens on x86 and aarch64 Linux. With the correct timing, I expect any platform would be affected.