The Deadlock Dinner
The Deadlock Dinner — CodePuz Puzzles · Concurrency The Deadlock Dinner Can you spot who'll starve before they ever eat? June 2026 · CodePuz · 8 min read In the last post we talked about RAII — and how a mutex that never gets unlocked can freeze an entire multithreaded system into silence. But that story assumed the bug was accidental: a forgotten unlock on an early return path. Today's puzzle is about something more insidious. A deadlock that happens even when every programmer did exactly what they were supposed to. Every thread locks a mutex. Every thread eventually unlocks it. The code looks correct. And yet, the system still seizes. To see why, we go to dinner. The Setup Edsger Dijkstra's Dining Philosophers is one of the most famous thought experiments in computer science. Five philosophers sit at a round table. Between each adjacent pair of philosophers lies a single fork. ...