jclass
Class SimpleBarrier

java.lang.Object
  |
  +--jclass.SimpleBarrier

public class SimpleBarrier
extends java.lang.Object

A barrier. It is a class that is used by parallel running threads to sync each other. It has a method that, when called, stops any thread that calls it until a certain number of calls do occur, then every thread goes on.

Written: Radu Sion
Version: 0.11
Source: SimpleBarrier.java

Visit Smart Software 


Constructor Summary
SimpleBarrier(int N)
          Creates a new SimpleBarrier.
 
Method Summary
 void enter()
          Enqueues the current thread at this barrier, waiting for all the others to join, that is waiting until N (see constructor) threads reached enter().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleBarrier

public SimpleBarrier(int N)
Creates a new SimpleBarrier. N represents the number of simultaneous threads that must call the .enter() method BEFORE the enter() method exits in each of them. That is enter() is blocking until N threads call it, then each of them goes on. No parameter checkings performed.
Parameters:
N - See description above.
Method Detail

enter

public void enter()
Enqueues the current thread at this barrier, waiting for all the others to join, that is waiting until N (see constructor) threads reached enter(). (Remember it is blocking !) Then it exits.