快捷搜索:  xxx  as  推理研究所  幼幼  侦探研究所

钱柜老虎机手机客户端:关于多线程同步的初步教程--Barrier的设计及使用



Barrier是一个多线程编程中常常要用到的同步对象,尤其多用于大年夜数据量的谋略历程中的同步。本文以广为流程的Doug Lea的concurrent对象包的Barrier实现为例,进行一点探究。在Doug Lea的concurrent对象包中,Barrier是一个接口,在concurrent包中供给了两个Barrier的实现:CyclicBarrier和Rendezvous。下面是Barrier接口的定钱柜老虎机手机客户端义:

public interface Barrier {

/**

* Return the number钱柜老虎机手机客户端 of parties that must meet per barri钱柜老虎机手机客户端er

* point. The number of parties is always at least 1.

**/

public int parties();

/**

* Returns true if the barrier has been compromised

* by threads leaving the barrier before a synchronization

* point (normally due to interruption or time钱柜老虎机手机客户端out).

* Barrier methods in implementation classes throw

* thr钱柜老虎机手机客户端ow BrokenBarrierException upon detection of breakage.

* Implementations may also support some means

* to clear this status.

**/

public boolean broken();

}

免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

您可能还会对下面的文章感兴趣: