!7 static Lock a = fairLock(); static Lock b = fairLock(); p-tt { centerHigherConsole(); startDeadlockDetector(); print("Initiating deadlock... :-)\n"); thread "A" { a.lock(); try { print("Thread A has lock A."); sleep1Second(); print("Thread A getting lock B."); b.lock(); try { print("Thread A sleeping."); main.sleep(); } finally { b.unlock(); } } finally { a.unlock(); } } thread "B" { b.lock(); try { print("Thread B has lock B."); sleep1Second(); print("Thread B getting lock A."); a.lock(); try { print("Thread B sleeping."); main.sleep(); } finally { a.unlock(); } } finally { b.unlock(); } } sleepQuietly(); }