今天晚上碰到个问题:写个main方法记录下

  

package com.zhuanche.service;

import java.util.concurrent.CountDownLatch;

/**
 * @Author fht
 * @Description
 * @Date 2020/1/9 下午10:13
 * @Version 1.0
 */
public class Test {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(10);
        for(int i = 1;i<10;i++){
            System.out.println(i+"++");
            countDownLatch.countDown();
          //  countDownLatch.await();

        }
        countDownLatch.await();
    }
}

标红部分如果是1,不是0,整个main方法会一直出不来。只有改成1才行,先记录下。有空看源码

版权声明:本文为thinkingandworkinghard原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/thinkingandworkinghard/p/12185861.html