What Is a Deadlock?

A deadlock occurs when two or more processes or threads are each waiting for a resource the other holds, so none of them can ever proceed.

Published October 7, 2026

A deadlock occurs when two or more processes or threads are each waiting for a resource the other holds, so none of them can ever proceed.

Why it exists

  • Deadlocks typically require four conditions simultaneously: mutual exclusion, holding a resource while waiting for another, no forced release, and a circular wait between the parties involved
  • They commonly occur when code acquires multiple locks in a different order in different places

How to apply it

  • Always acquire multiple locks in a consistent, agreed-upon order throughout the codebase to eliminate circular waits
  • Use timeouts on lock acquisition so a stuck process can detect the problem and back off rather than waiting forever

FAQ

Can a deadlock happen with a single lock?

Not typically — deadlocks generally require at least two resources being acquired in conflicting orders by at least two different threads or processes.

More General articles