When running in a very slow enviorment the deadlock threads don't have enought time to reach the deadlock.
But as they may block during creation it's faulty to assume that a blocked thread is blocking on the deadlock LOCK.
Main thread should check top frame so it know that the threads are at the deadlock site. Otherwise wait and check again.
This hack fixes the issue in this slow enviroment (QEMU with software emulated vector instructions):
diff --git a/test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java b/test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java
index 91b31c41be3..48411ec538d 100644
--- a/test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java
+++ b/test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java
@@ -92,6 +92,7 @@ public static void main(String[] args) throws Exception {
System.out.println("Waiting for thread1 and thread2 to deadlock ...");
awaitBlocked(thread1);
awaitBlocked(thread2);
+ try { Thread.sleep(1000); } catch (Exception e) {}
ThreadMXBean bean = ManagementFactory.getPlatformMXBean(ThreadMXBean.class);
long[] deadlockedThreads = sorted(bean.findMonitorDeadlockedThreads());
But as they may block during creation it's faulty to assume that a blocked thread is blocking on the deadlock LOCK.
Main thread should check top frame so it know that the threads are at the deadlock site. Otherwise wait and check again.
This hack fixes the issue in this slow enviroment (QEMU with software emulated vector instructions):
diff --git a/test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java b/test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java
index 91b31c41be3..48411ec538d 100644
--- a/test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java
+++ b/test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java
@@ -92,6 +92,7 @@ public static void main(String[] args) throws Exception {
System.out.println("Waiting for thread1 and thread2 to deadlock ...");
awaitBlocked(thread1);
awaitBlocked(thread2);
+ try { Thread.sleep(1000); } catch (Exception e) {}
ThreadMXBean bean = ManagementFactory.getPlatformMXBean(ThreadMXBean.class);
long[] deadlockedThreads = sorted(bean.findMonitorDeadlockedThreads());
- relates to
-
JDK-8345062 RISC-V: VirtualThreadDeadlocks.java failed with Zacas
-
- Closed
-