liveBook · Manning

Complex deadlock

As explained in Troubleshooting Java, Second Edition

A complex deadlock is a deadlock involving a chain of more than two threads in which each thread blocks another.

A complex deadlock is a circular wait involving more than two threads: thread A blocks B, B blocks C, and C blocks A. Longer chains are harder to find, understand, and solve. section 8.2.1

Investigate the thread dump as a chain of blocking relationships:

  • Remove threads that are not blocked. section 8.2.1
  • Start with a blocked thread and use its waiting lock ID to find what blocks it. section 8.2.1
  • Repeat for each thread; returning to an already investigated thread confirms a deadlock. section 8.2.1
  • Distinguish cascading blocked threads: their chain ends with an external event rather than a circular lock dependency. section 8.2.1

Three-thread cycle

Thread A holds one lock and waits for a second; thread B holds that second lock and waits for a third; thread C holds the third and waits for A’s lock. The cycle prevents progress. section 8.2.1

How Troubleshooting Java, Second Edition covers it

How deep it goes
Explains a practical lock-ID tracing procedure and distinguishes cycles from external-event cascades.
Examples
Uses a three-thread A-B-C cycle and producer-consumer lock ownership to illustrate circular blocking.
What it assumes
Assumes familiarity with threads and locks while teaching lock-ID tracing from blocked-thread details.
What you can do after
Diagnose/debug with thread dumps by tracing blocked threads until a circular dependency or external wait appears.
How it connects
Connects thread dumps, lock IDs, simple deadlocks, and cascading blocked threads.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java, Second Edition. The section links point to the parts of the book it draws on.