我需要一个 java.lang.Thread 来等待不可预测数量的前驱线程完成,作为“阻塞点”,然后再释放另一批线程的产生。 CountDownLatch 似乎如果有一个用于 countUp 和 countDown 的方法就可以工作。
是否有这样的实现,或者我需要自己实现信号量奇点吗?
最佳答案
A reusable synchronization barrier, similar in functionality to CyclicBarrier and CountDownLatch but supporting more flexible usage.
Unlike the case for other barriers, the number of parties registered to synchronize on a phaser may vary over time. Tasks may be registered at any time . . . and optionally deregistered upon any arrival
关于java - java.util.concurrent.CountDownLatch 的实现是否可以处理向上递增的初始计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30496608/