本文介绍了CountDownLatch,CyclicBarrier和Phaser Concurrent类有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CountDownLatch CyclicBarrier Phaser并发班 es?
这些类充当同步器。它们如何彼此不同?

What is the difference between CountDownLatch, CyclicBarrier and Phaser Concurrent classes ?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类有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 02:34