JaVa
   

A Final Word on Deadlock

Deadlock is the technical term given to the state where you realize you've completely missed some glitch in your multitasking system that allows some threads to get stuck while simultaneously waiting for each other to wake the other up, generally speaking. An example of this could involve threads A and B and objects X and Y. Thread A obtains object X's monitor, and thread B obtains object Y's monitor. Thread A, while owning object X's monitor, waits for thread B to release its ownership on object Y's monitor. However, thread B, while owning object Y's monitor, then waits for thread A to release its ownership on object X's monitor, resulting in both threads getting stuck. This is an example of deadlock.

Generally speaking, deadlock is something you should always be aware of and take proper precautions to avoid. It's just a matter of properly analyzing the path that your threads can take.

JaVa
   
Comments