What this thread does
Do first: identify one JVM PID with jcmd -l, then request jcmd PID Thread.print -l under that JVM's effective user and group.
Short answer
As of November 2026, current Java diagnostic docs distinguish a thread waiting from a cycle of threads owning each other's locks. Capture successive dumps and connect each waiting thread to its lock owner. The diagnostic example reports a Java-level deadlock; a WAITING state alone does not (diagnostic example).
Choose / don't choose
- External dump: choose
Thread.print -lfor an incident without application changes; don't target a shared main-class name or PID0, which can address multiple JVMs (jcmd). - In-process detection: choose
ThreadMXBean.findDeadlockedThreads()for monitors and ownable synchronizers. UsefindMonitorDeadlockedThreads()only for monitor-only detection; neither detects cycles containing virtual threads (API). - No ownership cycle: inspect the unchanged stack for I/O, queue starvation or long contention instead of assuming every parked thread is deadlocked (diagnostic guide).
Not for: Java runtime upgrades or database transaction deadlocks.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
jcmd -l | List candidate processes; container JVMs may require ps in their process context | Current docs, November 2026 | jcmd |
jcmd pid help | Ask the selected JVM for available diagnostic commands | Current docs, November 2026 | jcmd |
Thread.print -l | Include java.util.concurrent locks; option default is false | Current docs, November 2026 | jcmd |
findDeadlockedThreads() | Monitor plus ownable-synchronizer cycles; returns IDs or null | Current platform-thread API | MXBean |
getThreadInfo(ids, true, true) | Include owned monitors and ownable synchronizers for detected platform-thread IDs | Current platform-thread API | MXBean |
Order of operations
1. Confirm the correct JVM and its effective user/group. For a JVM in a Docker process, use tools such as ps to find its PID; absence from the host's jcmd -l list does not establish that the JVM stopped (jcmd). 2. Capture jcmd PID Thread.print -l, wait an incident-appropriate interval, then capture again while the symptom persists. Repeat to distinguish movement from stable ownership; there is no universal collection interval. 3. For each blocked thread, note the awaited lock identity and the thread owning it. Follow owner → awaited lock → next owner until the chain terminates or returns to the starting thread. In Oracle's example, Thread2 owns one object and awaits Thread1's object, while Thread1 awaits Thread2's object (cycle example). 4. Compare the same ownership chain across dumps. Preserve the stacks and call sites before restarting; repair the application lock acquisition order or lock scope, then reproduce the affected operation under contention. This sequence is a diagnostic recommendation, not an automatic recovery promise.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
AttachNotSupportedException | Attach API cannot attach; wrong identity or inaccessible process context requires separate investigation | Recheck PID/context and effective user/group; preserve the concrete attach cause rather than declaring deadlock from attach failure | Attach API, jcmd requirements |
Found one Java-level deadlock: | A circular monitor wait appears in the diagnostic example | Trace both owned and awaited objects to the competing call sites; correct the application's lock order | Oracle example |
UnsupportedOperationException | Ownable-synchronizer monitoring is unsupported by the VM | Check isSynchronizerUsageSupported(); use monitor-only detection with its narrower scope | MXBean |
israkir's question asks whether Java can detect a deadlock; the current management API documents detection, not safe forced lock release.
Missing
- An all-clear from ThreadMXBean does not cover virtual-thread cycles.
Thread.printincludes platform and mounted virtual threads;Thread.dump_to_fileis the documented all-thread collection path, but requires separate interpretation (jcmd, MXBean).
Checked
2026-11-12; current Java jcmd, troubleshooting, management and attach API references plus the dated israkir question read. No JVM diagnostic commands executed.
Started from a post by @Oracle, packaged by the editor. Original post