问题描述
CountDownLatch
, CyclicBarrier
与 Phaser并发班
es?
这些类充当同步器。它们如何彼此不同?
What is the difference between CountDownLatch
, CyclicBarrier
and Phaser Concurrent class
es ?These classes works as a synchronizer. How they are different from each other?
推荐答案
CyclicBarrier可以通过调用reset()方法来重置Barrier到其初始状态。而CountDownLatch不能。 CountDownLatch对于诸如应用程序启动时间的一次性事件是有利的,并且循环障碍可以用于在循环事件的情况下。同时计算大问题等的解。
参考:
CyclicBarrier can be used by calling reset() method which resets Barrier to its initial State. Whereas CountDownLatch cannot. CountDownLatch is good for one time event like application start-up time and CyclicBarrier can be used to in case of recurrent event e.g. concurrently calculating solution of big problem etc.Reference: http://javarevisited.blogspot.in/2012/07/countdownlatch-example-in-java.html
对于Phasers,请参考:
For Phasers refer to this: http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Phaser.html
这篇关于CountDownLatch,CyclicBarrier和Phaser Concurrent类有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!