@@ -0,0 +1,2646 @@
+package org.concurrent.sort;%0A%0A/**%0A * User:shijingui%0A * Date:2019/2/24%0A * %C2%A0%0A */%0Apublic class TwoThreadWaitNotify %7B%0A    private int start = 1;%0A%0A    private boolean flag = false;%0A%0A    public static void main(String%5B%5D args) %7B%0A//        Object obj%0A        TwoThreadWaitNotify twoThread = new TwoThreadWaitNotify();%0A%0A        Thread evenThread = new Thread(new EvenNum(twoThread));%0A        evenThread.setName(%22EvenThread-%22);%0A%0A        Thread oddThread = new Thread(new OddNum(twoThread));%0A        oddThread.setName(%22Odd Thread-%22);%0A%0A        evenThread.start();%0A        oddThread.start();%0A    %7D%0A%0A    /**%0A     * %E5%81%B6%E6%95%B0%E7%BA%BF%E7%A8%8B%0A     */%0A    public static class EvenNum implements Runnable %7B%0A        private TwoThreadWaitNotify number;%0A%0A        public EvenNum(TwoThreadWaitNotify number) %7B%0A            this.number = number;%0A        %7D%0A%0A        @Override%0A        public void run() %7B%0A%0A            while (number.start %3C= 100) %7B%0A                synchronized (TwoThreadWaitNotify.class) %7B%0A                    if (number.flag) %7B%0A                        System.out.println(Thread.currentThread().getName() + %22    %E5%81%B6%E6%95%B0   %22 + number.start);%0A                        number.start++;%0A%0A                        number.flag = false;%0A                        TwoThreadWaitNotify.class.notify();%0A%0A                    %7D else %7B%0A                        try %7B%0A                            TwoThreadWaitNotify.class.wait();%0A                        %7D catch (InterruptedException e) %7B%0A                            e.printStackTrace();%0A                        %7D%0A                    %7D%0A                %7D%0A%0A            %7D%0A        %7D%0A    %7D%0A%0A%0A    /**%0A     * %E5%A5%87%E6%95%B0%E7%BA%BF%E7%A8%8B%0A     */%0A    public static class OddNum implements Runnable %7B%0A        private TwoThreadWaitNotify number;%0A%0A        public OddNum(TwoThreadWaitNotify number) %7B%0A            this.number = number;%0A        %7D%0A%0A        @Override%0A        public void run() %7B%0A            while (number.start %3C= 100) %7B%0A                synchronized (TwoThreadWaitNotify.class) %7B%0A                    if (!number.flag) %7B%0A                        System.out.println(Thread.currentThread().getName() + %22   %E5%A5%87%E6%95%B0   %22 + number.start);%0A                        number.start++;%0A%0A                        number.flag = true;%0A                        if (number.start == 1) %7B%0A%0A                        %7D%0A%0A%0A                        TwoThreadWaitNotify.class.notify();%0A                    %7D else %7B%0A                        try %7B%0A                            TwoThreadWaitNotify.class.wait();%0A                        %7D catch (InterruptedException e) %7B%0A                            e.printStackTrace();%0A                        %7D%0A                    %7D%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

add test