今天晚上碰到个问题:写个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才行,先记录下。有空看源码