@@ -0,0 +1,961 @@
+/**%0D%0A * %0D%0A */%0D%0Apackage com.concurrency;%0D%0A%0D%0A/**%0D%0A * @author Kaibo%0D%0A * %0D%0A */%0D%0Apublic class Deadlock %7B%0D%0A%09static class Friend %7B%0D%0A%09%09private final String name;%0D%0A%0D%0A%09%09public Friend(String name) %7B%0D%0A%09%09%09this.name = name;%0D%0A%09%09%7D%0D%0A%0D%0A%09%09public String getName() %7B%0D%0A%09%09%09return this.name;%0D%0A%09%09%7D%0D%0A%0D%0A%09%09public synchronized void bow(Friend bower) %7B%0D%0A%09%09%09System.out.format(%22%25s: %25s%22 + %22  has bowed to me!%25n%22, this.name,%0D%0A%09%09%09%09%09bower.getName());%0D%0A%09%09%09bower.bowBack(this);%0D%0A%09%09%7D%0D%0A%0D%0A%09%09public synchronized void bowBack(Friend bower) %7B%0D%0A%09%09%09System.out.format(%22%25s: %25s%22 + %22 has bowed back to me!%25n%22, this.name,%0D%0A%09%09%09%09%09bower.getName());%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A%09%09final Friend alphonse = new Friend(%22Alphonse%22);%0D%0A%09%09final Friend gaston = new Friend(%22Gaston%22);%0D%0A%09%09new Thread(new Runnable() %7B%0D%0A%09%09%09public void run() %7B%0D%0A%09%09%09%09alphonse.bow(gaston);%0D%0A%09%09%09%7D%0D%0A%09%09%7D).start();%0D%0A%09%09new Thread(new Runnable() %7B%0D%0A%09%09%09public void run() %7B%0D%0A%09%09%09%09gaston.bow(alphonse);%0D%0A%09%09%09%7D%0D%0A%09%09%7D).start();%0D%0A%09%7D%0D%0A%7D%0D%0A

Add deadLock demo.