Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
The dining philosophers problem is the canonical illustration of deadlock, and understanding it pays off every time you hold two locks at once. Five philosophers at a circular table each need both neighboring forks to eat, but there's only one fork between each pair. When all five reach for the fork on their left simultaneously, everyone holds one fork and waits for the fork on their right — and nobody eats, forever. The real-world version is any situation where two threads each hold a lock the other needs: thread A holds lock 1 and waits for lock 2, thread B holds lock 2 and waits for lock 1. Recognizing the dining philosophers pattern in real code is the first step to preventing it.
Five philosophers sit around a circular table. Between each pair there is one fork. A philosopher needs both neighboring forks to eat. They all reach left at the same instant.
Everyone is holding one fork, waiting for the one on their right. Nobody eats. Nobody puts a fork down. The system is frozen. This is a deadlock.
Don't implement it yet — just let the picture sink in. We'll revisit in the Deadlocks module.