|
Java™ by example!
|
|
|
How do I detect a deadlock with ThreadMBean in JDK 1.5?
This example shows how to use the ThreadMBean class in JDK 1.5 to detect a deadlock. ThreadMBean is a management class (package java.lang.management) that provides functionality to query the thread system of the JVM. The example creates three threads A, B and C which end up in a deadly embrace: A waits for a lock that B holds, B waits for a lock that C holds and C waits for a lock that A holds. The method findMonitorDeadlockedThreads returns the list of Thread ids involved in the deadlock. FindDeadlock.java:
outputs:
Further Information
Author of answer: Joris Van den Bogaert
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|