--- old/test/hotspot/jtreg/runtime/handshake/HandshakeDirectTest.java 2020-04-03 07:06:26.994778640 +0000 +++ new/test/hotspot/jtreg/runtime/handshake/HandshakeDirectTest.java 2020-04-03 07:06:26.133757963 +0000 @@ -24,6 +24,7 @@ /* * @test HandshakeDirectTest + * @bug 8240918 * @summary This test tries to stress direct handshakes between threads while suspending them. * @library /testlibrary /test/lib * @build HandshakeDirectTest @@ -60,8 +61,9 @@ } // Handshake directly some other worker - int handshakee = ThreadLocalRandom.current().nextInt(0, WORKING_THREADS-1); + int handshakee = ThreadLocalRandom.current().nextInt(0, WORKING_THREADS - 1); if (handshakee == me) { + // Pick another thread instead of me. handshakee = handshakee != 0 ? handshakee - 1 : handshakee + 1; } handshakeSem[handshakee].acquire(); @@ -108,7 +110,7 @@ @Override public void run() { while (true) { - int i = ThreadLocalRandom.current().nextInt(0, WORKING_THREADS-1); + int i = ThreadLocalRandom.current().nextInt(0, WORKING_THREADS - 1); workingThreads[i].suspend(); try { Thread.sleep(1); // sleep for 1 ms