Card 01/ 08
All 8 cards
ConceptDifficulty: Intermediate1 min
Two Threads, Two Locks, and Neither One Moving Again
A service stops responding. Nothing has crashed, the processor is idle, memory is fine, and the request threads have not moved in eleven minutes.
Each thread is holding a lock and waiting for one the other holds. Neither can release what it has until it gets what it wants, and neither will ever get it.
That closed cycle is a deadlock, and it has two properties worth knowing before anything else. It is permanent — nothing times out, nothing retries, no thread gives up. And it is silent: no exception, no log line, and a thread dump is the only thing that shows it.
So a deadlock is not a rare mystery. It is a cycle in a graph, and everything in this topic is about seeing the cycle before it closes.