Operating systems · interactive
Deadlocks
Two threads, two locks. Each grabs one and then waits for the other's. Nothing crashes; nothing happens, forever. The fix is a rule, not more code.
Thread T1
holds: nothing
waits for: —
Thread T2
holds: nothing
waits for: —
lock A
free
lock B
free
T1 needs A then B. T2 needs B then A.
Lock order
1 A thread keeps the lock it has while it waits for the next one.
Fine on its own.
2 3 4
In production
Tools and technologies
Deadlocks appear in threads and in database transactions alike.
Not tied to one language — use these names when you search docs or design a system.