How do you detect a deadlock in a running JVM?
intermediateCore Java › Multithreading & Concurrency
Take a thread dump with jstack <pid> (or jcmd <pid> Thread.print, or kill -3). The dump ends with Found one Java-level deadlock: and lists the cycle. Programmatically use ThreadMXBean.findDeadlockedThreads().
- Does it detect deadlocks involving
ReentrantLock?findDeadlockedThreadsdoes (ownable synchronizers);findMonitorDeadlockedThreadsonly monitors. - Does it detect livelock? No.