KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > EDU > oswego > cs > dl > util > concurrent > Barrier


1
2 /*
3   File: Barrier.java
4
5   Originally written by Doug Lea and released into the public domain.
6   This may be used for any purposes whatsoever without acknowledgment.
7   Thanks for the assistance and support of Sun Microsystems Labs,
8   and everyone contributing, testing, and using this code.
9
10   History:
11   Date Who What
12   11Jun1998 dl Create public version
13 */

14
15 package EDU.oswego.cs.dl.util.concurrent;
16
17 /**
18  * Barriers serve
19  * as synchronization points for groups of threads that
20  * must occasionally wait for each other.
21  * Barriers may support any of several methods that
22  * accomplish this synchronization. This interface
23  * merely expresses their minimal commonalities:
24  * <ul>
25  * <li> Every barrier is defined for a given number
26  * of <code>parties</code> -- the number of threads
27  * that must meet at the barrier point. (In all current
28  * implementations, this
29  * value is fixed upon construction of the Barrier.)
30  * <li> A barrier can become <code>broken</code> if
31  * one or more threads leave a barrier point prematurely,
32  * generally due to interruption or timeout. Corresponding
33  * synchronization methods in barriers fail, throwing
34  * BrokenBarrierException for other threads
35  * when barriers are in broken states.
36  * </ul>
37  * <p>[<a HREF="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
38
39  **/

40 public interface Barrier {
41
42
43   /**
44    * Return the number of parties that must meet per barrier
45    * point. The number of parties is always at least 1.
46    **/

47
48   public int parties();
49
50   /**
51    * Returns true if the barrier has been compromised
52    * by threads leaving the barrier before a synchronization
53    * point (normally due to interruption or timeout).
54    * Barrier methods in implementation classes throw
55    * throw BrokenBarrierException upon detection of breakage.
56    * Implementations may also support some means
57    * to clear this status.
58    **/

59
60   public boolean broken();
61 }
62
Popular Tags