want to know what is deadlock condition in threads, because in many of the books i studied how to avoid deadlock situation, i just want to know what is deadlock situation and a example code for that?
Deadlock is a situation that a concurrent program cannot proceed.
A thread is waiting for another thread, while the other thread is waiting for the first thread's completion.
The commonly used real world example is a traffic flow.
No traffic can move until the other queue moves.
You may find a good discussion on deadlocks here.
Update : This is one java example I found on web (Oreilly book). It has comments on that so you can understand it easily.
Dining Philosophers problem is another good example to understand the deadlocks.
removed dead Imageshack link
Dead lock detection and Deadlock prevention are two of related areas that might be useful while learning about the deadlocks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With