Deadlock
Deadlock
A state where multiple processes are each waiting for the others to proceed, so none of them can move forward.
In Simple Terms
A deadlock is what happens when two or more tasks keep waiting for one another to proceed, and none of them can move. It comes from a mechanism that temporarily keeps other tasks from touching something that's in use, so that changes to data don't overlap. When it happens in a database or an app that runs many tasks at the same time, the processing can stop and things can look frozen. That's why people prevent it by deciding the order in which things get used, or by trying again when something still isn't free after waiting a while.
Behind the Name
The name comes from the idea of an impasse, a situation where nobody can move forward. "Dead" means completely stopped, and "lock" means fastened in place. Put together, they describe two things gripping each other so tightly that neither one can move.
Take a Closer Look!
A deadlock is a situation where several processes are each waiting for the others to finish their work, so none of them can move forward.
The processes involved end up frozen, and they can't move forward as things stand. Some systems can detect this automatically and stop some of the processes so the rest can keep going.
This happens when multiple processes try to use two or more pieces of data or resources one after another. Real computers have a mechanism that blocks other processes from touching something while it's in use, so that two processes can't change the same data at once and corrupt it.
Think of it like this: Person A holds onto the scissors while waiting for the glue, and Person B holds onto the glue while waiting for the scissors. Since neither of them will put down the tool they're holding first, neither one can keep working.
Deadlocks are a problem in databases used by lots of people at once, and in systems that run many tasks in parallel. When one happens, the processes involved get stuck, and the screen of an app or service may stop responding.
That's why developers use tricks to prevent these standstills, like deciding in advance the order in which data gets used, or trying again when something still isn't free after waiting a set amount of time.