@@ -0,0 +1,3390 @@
+package com.njust.test.learn;%0A%0Aimport java.util.concurrent.locks.Condition;%0Aimport java.util.concurrent.locks.Lock;%0Aimport java.util.concurrent.locks.ReentrantLock;%0A%0A/**%0A * %E9%A2%98%E7%9B%AE%E8%A6%81%E6%B1%82%EF%BC%9A%0A * 3%E4%B8%AA%E7%BA%BF%E7%A8%8B%E4%BE%9D%E6%AC%A1%E6%89%93%E5%8D%B0%EF%BC%9A12 A a 34 B b%0A * %E5%8D%B3%E7%BA%BF%E7%A8%8B1%E6%89%93%E5%8D%B012,34,56,...5152%0A * %E7%BA%BF%E7%A8%8B2%E6%89%93%E5%8D%B0A,B,C...Z%0A * %E7%BA%BF%E7%A8%8B3%E6%89%93%E5%8D%B0a,b,c...z%0A * %E8%80%8C%E4%B8%94%E8%A6%81%E6%9C%89%E5%BA%8F%E8%BF%9B%E8%A1%8C%0A */%0Apublic class LockConditionDemo2%0A%7B%0A    public static void main(String%5B%5D args)%0A    %7B%0A        PrintManage printManage = new PrintManage();%0A        new Thread(printManage::print1).start();%0A        new Thread(printManage::print2).start();%0A        new Thread(printManage::print3).start();%0A    %7D%0A    %0A    static class PrintManage%0A    %7B%0A        private Lock lock = new ReentrantLock();%0A        %0A        private Condition condition1 = lock.newCondition();%0A        %0A        private Condition condition2 = lock.newCondition();%0A        %0A        private Condition condition3 = lock.newCondition();%0A        %0A        private int turn = 1;%0A        %0A        void print1()%0A        %7B%0A            for (int i = 1; i %3C= 26; i++)%0A            %7B%0A                lock.lock();%0A                try%0A                %7B%0A                    while (turn != 1)%0A                    %7B%0A                        try%0A                        %7B%0A                            condition1.await();%0A                        %7D%0A                        catch (InterruptedException e)%0A                        %7B%0A                            e.printStackTrace();%0A                        %7D%0A                    %7D%0A                    %0A                    System.out.print((2 * i - 1) + %22,%22 + 2 * i);%0A                    turn = 2;%0A                    condition2.signal();%0A                    %0A                %7D%0A                finally%0A                %7B%0A                    lock.unlock();%0A                %7D%0A            %7D%0A        %7D%0A        %0A        void print2()%0A        %7B%0A            for (char i = 'A'; i %3C= 'Z'; i++)%0A            %7B%0A                lock.lock();%0A                try%0A                %7B%0A                    while (turn != 2)%0A                    %7B%0A                        try%0A                        %7B%0A                            condition2.await();%0A                        %7D%0A                        catch (InterruptedException e)%0A                        %7B%0A                            e.printStackTrace();%0A                        %7D%0A                    %7D%0A                    %0A                    System.out.print(i);%0A                    turn = 3;%0A                    condition3.signal();%0A                    %0A                %7D%0A                finally%0A                %7B%0A                    lock.unlock();%0A                %7D%0A            %7D%0A        %7D%0A        %0A        void print3()%0A        %7B%0A            for (char i = 'a'; i %3C= 'z'; i++)%0A            %7B%0A                lock.lock();%0A                try%0A                %7B%0A                    while (turn != 3)%0A                    %7B%0A                        try%0A                        %7B%0A                            condition3.await();%0A                        %7D%0A                        catch (InterruptedException e)%0A                        %7B%0A                            e.printStackTrace();%0A                        %7D%0A                    %7D%0A                    %0A                    System.out.println(i);%0A                    turn = 1;%0A                    condition1.signal();%0A                %7D%0A                finally%0A                %7B%0A                    lock.unlock();%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Create LockConditionDemo2.java