Deadlocks
What a deadlock is and how to prevent one: the four Coffman conditions, a reproducible Java deadlock, finding it with a thread dump, prevention through lock ordering, timeouts and fewer locks, database deadlocks and retries, and the related problems of livelock and starvation.
CodexBash, , 5 min read
A deadlock is a standstill: two or more threads (or transactions, or processes) are each waiting for something another one holds, so none of them can ever continue. The program does not crash and logs nothing; it simply stops making progress, with CPU usage near zero, while requests pile up. Deadlocks are among the most frustrating concurrency bugs because they appear rarely, under load, and vanish when you add logging. This article explains why they happen, shows how to find one, and covers the techniques that prevent them.
Sign in to read the rest
The whole 5 minute article is free with an account, along with every problem, lesson and tutorial. No card.