org.apache.jdo.tck.util
Class RogueBarrier

java.lang.Object
  extended byorg.apache.jdo.tck.util.RogueBarrier

public class RogueBarrier
extends java.lang.Object

Allows a set of threads to wait for all to reach a common barrier point.

The RogueBarrier uses a rigorous breakage model: No thread can leave a barrier point prematurely. All attempts to interrupt an awaiting thread via an InterruptedException are being ignored.

Author:
Martin Zaun

Nested Class Summary
static class RogueBarrier.Test
           
 
Constructor Summary
RogueBarrier(int parties)
          Creates a new RogueBarrier that will trip when the given number of parties (threads) are waiting upon it.
 
Method Summary
 int await()
          Waits until all parties have invoked await on this barrier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RogueBarrier

public RogueBarrier(int parties)
Creates a new RogueBarrier that will trip when the given number of parties (threads) are waiting upon it.

Parameters:
parties - the number of threads that must invoke await() before the barrier is tripped.
Throws:
java.lang.IllegalArgumentException - if parties is less than 1.
Method Detail

await

public int await()
Waits until all parties have invoked await on this barrier.

Returns:
the arrival index of the current thread, where index parties - 1 indicates the first to arrive and zero indicates the last to arrive.


Copyright © 2005-2007 Apache Software Foundation. All Rights Reserved.