Long time ago, I saved a sentence from a Java reference book: \"Java has no mechanism to handle deadlock. it won\'t even know deadlock occurred.\" (Head First Java 2nd E
you have to modify the code a little bit in the Deadlock Class
Deadlock() { Therad t = new Thread(this); // modified t.start(); System.out.println(); //any instruction to delay a.methodA(b); }
Also the above code will not always cause a dead lock, only some times it may happen.