@@ -0,0 +1,1814 @@
+package ThreadDemo;%0A%0A/**%0A * @author chengangw%0A * @date 23/2/2017 2:56 PM%0A */%0Apublic class ThreadDeadLock %7B%0A%0A    static class DeadLock %7B%0A%0A        private final Object right = new Object();%0A        private final Object left = new Object();%0A%0A        public void leftRight() throws InterruptedException %7B%0A            synchronized (left) %7B%0A                Thread.sleep(2000);%0A                synchronized (right) %7B%0A                    System.out.println(%22leftRight end%22);%0A                %7D%0A            %7D%0A        %7D%0A%0A        public void rightLeft() throws InterruptedException %7B%0A            synchronized (right) %7B%0A                Thread.sleep(2000);%0A                synchronized (left) %7B%0A                    System.out.println(%22rightLeft end%22);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    static class MyThreadDl01 extends Thread %7B%0A        private DeadLock deadLock;%0A%0A        public MyThreadDl01(DeadLock deadLock) %7B%0A            this.deadLock = deadLock;%0A        %7D%0A%0A        public void run() %7B%0A            try %7B%0A                deadLock.leftRight();%0A            %7D catch (InterruptedException e) %7B%0A                e.printStackTrace();%0A            %7D%0A        %7D%0A    %7D%0A%0A    static class MyThreadDl02 extends Thread %7B%0A        private DeadLock deadLock;%0A%0A        public MyThreadDl02(DeadLock deadLock) %7B%0A            this.deadLock = deadLock;%0A        %7D%0A%0A        public void run() %7B%0A            try %7B%0A                deadLock.rightLeft();%0A            %7D catch (InterruptedException e) %7B%0A                e.printStackTrace();%0A            %7D%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        DeadLock dl = new DeadLock();%0A        MyThreadDl01 myThreadDl01 = new MyThreadDl01(dl);%0A        MyThreadDl02 myThreadDl02 = new MyThreadDl02(dl);%0A        myThreadDl01.start();%0A        myThreadDl02.start();%0A    %7D%0A%7D%0A

Add Thread DeadLock