Java Program for a Deadlock
public class DeadLock{ public static void main(String[] args) throws InterruptedException { final Object obj = new Object(); final Object obj1 = new Object(); Thread t = new Thread() { public void run() { while (true) { synchronized (obj) { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } synchronized (obj1) { } } } } }; t.start(); while (true) { synchronized (obj1) { Thread.sleep(1000); synchronized (obj) { } } } } } Login with Facebook