What is Deadlock in Programming

Programming theory

Steven Curtis
5 min readMay 24, 2022


Photo by Denys Nevozhai on Unsplash

A deadlock is a classic problem in Computer Science.

In some sense during the early days of computing Deadlock was mitigated as a problem somewhat as they would only run one program at a time, so any given program would be able to manage it’s own resources and be sure that they are available when required.

Modern machines tend to have sophisticated Operating Systems that manage resources for programs which can then run in the same time-space.

There is a difficulty in programming though: You can end up with a Deadlock situation if you do not take proper care of your resources.


Sync dispatching: means that the thread where the task is dispatched has to pause and finish executing the task before resuming.
Async dispatching: means that the thread can be dispatched and does not wait for the task to finish executing.
Preemption: Temporarily interrupting a task with the intention of resuming it at a later time.

Why should we care?

Theory is one compelling reason, and then the application of that theory. The fact that heavyweights like Dijkstra and Tony Hoare have rounded out the problem should mean something.

The theoretical problem

Five philosophers have a place sat at a table. Each philosopher requires two forks to eat the speciality food placed in front of them. Each philosopher has two forks in front of them, and so this apparently leads to no issue with all the participant philosophers eating at once. However, a second look at the layout seems to suggest all of the forks need to be shared — since the philosophers are sitting in a circle.

Five philosophers, each sitting at their own plate require two forks in order to eat their food