-3

I have been trying to find whether JVM has some way to find if some threads are in deadlock condition. I am unable to find any. Please let me know if any one of you gets any pointer on this.

Nishant
  • 407
  • 2
  • 4
  • 12

2 Answers2

1

You can use the ThreadMXBean JMX bean.

ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
ThreadInfo[] threadInfos = threadMXBean.dumpAllThreads(true, true);
long[] deadlockedThreads = threadMXBean.findDeadlockedThreads();
long[] monitorDeadlockedThreads = threadMXBean.findMonitorDeadlockedThreads();
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
0

No, the JVM itself does not support deadlock detection.
There is a thread that deals with JVM and deadlocks, which is also marked as resolved: Link

Community
  • 1
  • 1
Strike
  • 248
  • 1
  • 8