Previous | Next --- Slide 31 of 60
Back to Lecture Thumbnails
aman0456

Here's why the code in this slide is bound to produce a deadlock. A classic case of deadlocks is when a thread attempts to acquire (or release) two (or more) locks in different orders. This is what happens when you execute transfer(A,B,100) and transfer(B,A,200) simultaneously. One thread holds the lock to A, the other to B and each is waiting for a chance to acquire the lock they don't have.

Please log in to leave a comment.