Card 08/ 08
All 8 cards
RecapDifficulty: Advanced1 min
Four Conditions, and the One Worth Removing
Five things this topic established, and where each one was.
| The thing | Where |
|---|---|
| A deadlock is a cycle of threads each holding what another wants | Two Threads, Two Locks |
| Two correct methods taking the same locks in opposite orders is enough | A Transfer Between Two Accounts |
| Four conditions must hold at once; removing any one prevents it | The Four Conditions a Deadlock Needs |
| A global lock ordering is the condition you can remove for free | Fixing the Transfer by Giving the Two Locks an Order |
| Idle threads stuck is deadlock; busy threads stuck is livelock | Deadlock, Livelock and Starvation |
No single method can deadlock on its own, so no amount of reading one method will find it. What causes a deadlock is two pieces of code disagreeing about an order, and the fix is a decision the whole program keeps.