@@ -0,0 +1,1933 @@
+package com.njust.test.learn;%0A%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.Date;%0Aimport java.util.concurrent.CountDownLatch;%0A%0A/**%0A * 1.%E6%A8%A1%E6%8B%9F%E8%A3%81%E5%88%A4%E5%90%B9%E5%8F%A3%E5%93%A8%EF%BC%8C%E7%84%B6%E5%90%8E%E6%89%80%E6%9C%89%E8%BF%90%E5%8A%A8%E5%91%98%E5%BC%80%E5%A7%8B%E8%B7%91%EF%BC%9B%0A * 2.%E6%A8%A1%E6%8B%9F%E6%89%80%E6%9C%89%E8%BF%90%E5%8A%A8%E5%91%98%E8%B7%91%E5%AE%8C%E5%90%8E%EF%BC%8C%E8%A3%81%E5%88%A4%E7%BB%9F%E8%AE%A1%E6%88%90%E7%BB%A9%E4%BF%A1%E6%81%AF%0A */%0Apublic class CountDownLatchDemo%0A%7B%0A    private static final int RUNNER_COUNT = 5;%0A    %0A    public static void main(String%5B%5D args)%0A    %7B%0A        %0A        CountDownLatch startLatch = new CountDownLatch(1);%0A        CountDownLatch finishLatch = new CountDownLatch(RUNNER_COUNT);%0A        %0A        for (int i = 0; i %3C RUNNER_COUNT; i++)%0A        %7B%0A            final int index = i + 1;%0A            new Thread(() -%3E %7B%0A                try%0A                %7B%0A                    printLog(%22%E8%BF%90%E5%8A%A8%E5%91%98%22 + index + %22%E5%87%86%E5%A4%87%E5%87%BA%E5%8F%91%22);%0A                    startLatch.await();%0A                    printLog(%22%E8%BF%90%E5%8A%A8%E5%91%98%22 + index + %22%E5%B7%B2%E7%BB%8F%E5%87%BA%E5%8F%91%22);%0A                    %0A                    Thread.sleep((long)(Math.random() * 10000));%0A                    printLog(%22%E8%BF%90%E5%8A%A8%E5%91%98%22 + index + %22%E5%B7%B2%E7%BB%8F%E8%BE%BE%E5%88%B0%22);%0A                    finishLatch.countDown();%0A                %7D%0A                catch (InterruptedException e)%0A                %7B%0A                    e.printStackTrace();%0A                %7D%0A            %7D).start();%0A        %7D%0A        %0A        try%0A        %7B%0A            Thread.sleep(5000);%0A        %7D%0A        catch (InterruptedException e)%0A        %7B%0A            e.printStackTrace();%0A        %7D%0A        printLog(%22%E8%A3%81%E5%88%A4%E5%87%86%E5%A4%87%E5%8F%91%E5%91%BD%E4%BB%A4%22);%0A        startLatch.countDown();%0A        printLog(%22%E8%A3%81%E5%88%A4%E5%87%86%E5%A4%87%E5%B7%B2%E7%BB%8F%E5%8F%91%E5%87%BA%E5%91%BD%E4%BB%A4,%E6%AD%A3%E5%9C%A8%E7%AD%89%E5%BE%85%E7%BB%93%E6%9E%9C%22);%0A        %0A        try%0A        %7B%0A            finishLatch.await();%0A            printLog(%22%E6%89%80%E6%9C%89%E4%BA%BA%E8%B7%91%E5%AE%8C%E4%BA%86,%E8%A3%81%E5%88%A4%E5%8F%91%E5%B8%83%E7%BB%93%E6%9E%9C%22);%0A        %7D%0A        catch (InterruptedException e)%0A        %7B%0A            e.printStackTrace();%0A        %7D%0A        %0A    %7D%0A    %0A    private static void printLog(String msg)%0A    %7B%0A        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(%22HH:mm:ss%22);%0A        String dateStr = simpleDateFormat.format(new Date());%0A        System.out.println(%22%5B%22 + dateStr + %22%5D %22 + Thread.currentThread().getName() + %22 %22 + msg);%0A    %7D%0A%7D%0A

Create CountDownLatchDemo.java