DeadlocksLivelock & StarvationMedium⏱️ ~2 min

Starvation vs Livelock vs Deadlock

Key Insight
All three are progress failures, but they differ in who makes progress and how threads behave. Deadlock: nobody progresses, all blocked. Livelock: nobody progresses, all busy. Starvation: some progress, some wait forever.
Progress Comparison
DEADLOCKAll blocked0% CPU, 0 workLIVELOCKAll running100% CPU, 0 workSTARVATIONSome progressWork done, unfairCircular waitEasy to detectRetry stormsHard to detectPriority issuesLatency spikes

The Traffic Analogy

Deadlock: Four cars at a four-way intersection, each waiting for the car on their right. Nobody moves. Traffic completely stops.

Livelock: Two cars at a narrow bridge. Both inch forward, both see the other, both back up. Both inch forward again. They keep moving but neither crosses.

Starvation: Highway on-ramp during rush hour. Highway traffic flows fine. But cars on the ramp wait for a gap that never comes.

Detection Difficulty

Deadlock: Easiest to detect. Threads are blocked. Stack traces show waiting threads. Timeout monitoring catches it.

Starvation: Medium difficulty. Tail latency spikes reveal it. Some requests take forever while averages look fine.

Livelock: Hardest to detect. CPU is busy, threads are running, health checks pass. Only throughput metrics reveal the problem.

Remember: Deadlock = stuck waiting. Livelock = busy doing nothing. Starvation = others cut in line forever.
💡 Key Takeaways
Deadlock: all threads blocked, 0% CPU usage, easy to detect via blocked thread monitoring
Livelock: all threads busy, 100% CPU usage, zero throughput - hardest to detect
Starvation: system works but unfairly - some threads never get resources
Traffic analogy: deadlock is gridlock, livelock is two cars dancing, starvation is stuck on-ramp
Detection: deadlock (stack traces), starvation (tail latency), livelock (throughput metrics)
📌 Examples
1Deadlock: Thread A has Lock1 waiting for Lock2, Thread B has Lock2 waiting for Lock1
2Livelock: Two Ethernet adapters detect collision, back off same time, transmit same time, repeat
3Starvation: Writer thread waits 30 seconds while readers continuously enter critical section
← Back to Livelock & Starvation Overview