!7 static new O a; static new O b; p-tt { centerHigherConsole(); doEvery_daemon(1000, r { L lockingThreads = printDeadlocks(); if (nempty(lockingThreads)) { print("Interrupting locking threads."); L threads = threadInfosToThreads(lockingThreads); print("Interrupting " + n(threads, "thread")); for (Thread t : threads) t.interrupt(); } }); print("Initiating deadlock... :-)\n"); thread "A" { synchronized(a) { print("Thread A has lock A."); sleep1Second(); print("Thread A getting lock B."); synchronized(b) { print("Thread A sleeping."); main.sleep(); } } } thread "B" { synchronized(b) { print("Thread B has lock B."); sleep1Second(); print("Thread B getting lock A."); synchronized(a) { print("Thread B sleeping."); main.sleep(); } } } sleepQuietly(); }