Simple Deadlock Explanation - CodeByAkram

Simple Deadlock Explanation

Deadlock Explanation with Example.


Deadlock means, it is a situation where 2 or more threads are blocked and waiting for each other.

Let's take an example, in the office we have shared printer and scanner where employees has ability to do scanning and printing.

1. Deepak has bunch of documents that it wants to print first and also want to take a scan later.
(Print and Scan)
2. Rohit has bunch of documents that it wants to scan first and also want to take a print later.
(Scan and Print)

Thread 1 ------ (Got Printer) ------ (Need to Scan) (Blocked)
Thread 2 -------(Got Scanner) -----(Need to Print) (Blocked)


No comments:

Post a Comment