An Example of Deadlock

Two concurrent processes, P and Q, try to access the same critical section protected by two locks, M and N.

You may wish to enlarge your viewing window.


Code for Process P Code for Process Q
Lock(M) Lock(N)
Lock(N) Lock(M)
Critical Section Critical Section
Unlock(N) Unlock(M)
Unlock(M) Unlock(N)


This needs Java to execute