A deadlock is a standstill where two or more threads each wait for a resource another holds. None can proceed, so all stay stuck forever. The program hangs without crashing.
All four Coffman conditions must hold at once:
Mutual exclusion: only one thread can hold a resource.
Hold and wait: a thread keeps what it has while waiting for more.
No preemption: you cannot forcibly take a resource away.
Circular wait: a cycle of threads each waits on the next.
Break any one and deadlock cannot form. The most common fix targets circular wait by making every thread acquire locks in the same order.
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Instead of lock ordering, how could you break hold and wait, and what would that cost you?Take every lock up front, or release everything and retry when one is busy. The cost is less concurrency, wasted work and a risk of livelock.
How is livelock different from deadlock?In livelock the threads keep running and reacting to each other but make no progress. Give an example, such as two threads that back off and retry in step.
A deadlock is a standstill where two or more threads each wait for a resource another one holds, so none of them can ever move.
The program doesn't crash. It just hangs, and those threads stay stuck for good.
It needs four conditions, the Coffman conditions, and all four have to hold at the same time.
Mutual exclusion means only one thread can hold a resource, and hold and wait means a thread keeps what it has while it waits for more.
No preemption means you can't force a resource away from a thread, and circular wait means there's a cycle where each thread waits on the next.
Break any one and deadlock can't form. The usual fix breaks circular wait by taking locks in one fixed order, but every code path has to follow it, and one path that doesn't brings the risk back.
Weak answers to avoid
Recites the four names with no meaningFour labels sound memorized. Give each a one-line meaning, and keep hold and wait apart from circular wait, which weak answers often blur.
Thinks any one condition causes deadlockIt's the reverse. All four must hold at once, which is why breaking a single one is enough to prevent it.
Confuses deadlock with a crash or a raceA deadlock hangs, with threads stuck waiting. A race gives wrong results that depend on timing. Blurring the two reads as shaky basics.
Defines it but never says how to prevent itThe interviewer will ask how you stop it. Get there first and name a consistent lock order as the fix for circular wait.
Interview lens
Likely follow-ups, what you can say, and the weak answers to avoid.