java thread deadlock
GIAN Tutorials
10:07 PM
  Deadlock describes a situation where two or more threads are blocked forever, waiting for each other. Deadlock occurs when multiple threads need the same locks but obtain them in different order. A Java multithreaded program may suffer from the deadlock condition because the  synchronized  keyword causes the executing thread to block while waiting for the lock, or monitor, associated with the specified object. Here is an example.   Example   public  class  TestThread  {     public  static  Object  Lock1  =  new  Object ();     public  static  Object  Lock2  =  new  Object ();         public  static  void  main ( String  args [])  {        ThreadDemo1  T1 =  new  ThreadDemo1 ();        ThreadDemo2  T2 =  new  ThreadDemo2 ();        T1 . start ();        T2 . start ();     }         private  static  class  ThreadDemo1  extends  Thread  {        public  void  run ()  {           synchronized  ( Lock1 )  {              System . out . println ( "Thread 1: Holding lock 1..." );  ...
 
