CountDownLatch详解
CountDownLatch详解CountDownLatch用于控制多个线程执行完毕后再执行某一线程。1,首先初始化时,设置线程数量:CountDownLatch countDownLatch = new CountDownLatch(3);此时,设置AQS中state=3,CountDownLatch 内部类sync会继承AQS类。2,在A,B,C三个线程启动时,需要等待的线程执行await()方法:countDownLatch.await(),此时,await方法调用sync.acquireS
原创
2021-05-11 16:00:30 ·
634 阅读 ·
0 评论