What is Thread Deadlock? How to avoid it?
A deadlock occurs when one object is waiting for another to release a lock, and that object is also waiting. A circular dependency occurs, and then the waiting thread will wait forever, or deadlocked.The key to prevent deadlock: Do not hold a lock while waiting another resource that also requires locking.Read from Sun’s tutorial: http://java.sun.com/docs/books/tutorial/essential/threads/deadlock.html Play with the famous Dining Philosopher Problem (not invented by Java!) Applet and learn the important concepts when you have fun.