Sunday, 2 March 2014

Dead Lock

Dead Lock
Dead lock is a situation where two or more threads block forever. In Operating system dead lock occurs, when one process or thread is waiting for a resource, where this resource is in use by other process, which in turn waiting for other resource.


Dead lock is a common problem in multi threading environment. Care must be taken while developing multi threading Applications.




As you see the above figure,
process p1, acquires the resource R1, and waiting for the resource R2
process p2 acquires the resource R2, and waiting for the resource R1.


P1 releases the resource R1, once it finishes its task, but to finish its task, p1 needs rsource R1, which is in use by p2, so process p1 waits infinitely. Same thing happen with p2 also. So it is a deadlock, where processes p1 and p2 waiting infinitely.


Why Wait & Notify in Object class                                                 Java Dead Lock Example                                                 Home

No comments:

Post a Comment