|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectmandala.util.ThreadBarrier
Instance of this class are barrier for a specified number of threads.
A barrier is a data structure that blocks until a specified number of threads have reached it. In this case, the barrier is released and threads are notified so they can continue their run.
| Field Summary | |
protected int |
count
The number of threads that must traverse this barrier before being unlocked. |
protected boolean |
released
The released state of this barrier. |
| Constructor Summary | |
ThreadBarrier(int count)
Creates a new ThreadBarrier instance. |
|
| Method Summary | |
int |
getCount()
Returns the number of threads that must traverse this barrier before releasing it. |
boolean |
isReleased()
Returns the released state of this barrier. |
void |
reuse(int count)
Reuse this instance as a new barrier. |
void |
synchronize()
Wait until count threads have reached this
barrier. |
boolean |
synchronize(long timeout)
Wait until count threads have reached this
barrier or the specified timeout
expires. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int count
The number of threads that must traverse this barrier before being unlocked.
protected boolean released
The released state of this barrier.
| Constructor Detail |
public ThreadBarrier(int count)
Creates a new ThreadBarrier instance.
count - The number of threads that must traverse this
barrier before being unlocked| Method Detail |
public int getCount()
Returns the number of threads that must traverse this barrier before releasing it.
public void synchronize()
throws InterruptedException
Wait until count threads have reached this
barrier.
InterruptedException - if an error occurs
public boolean synchronize(long timeout)
throws InterruptedException
Wait until count threads have reached this
barrier or the specified timeout
expires.
timeout - a long value
true if this barrier is released,
false otherwise.
InterruptedException - if an error occurspublic boolean isReleased()
Returns the released state of this barrier.
true if this barrier is released,
false oterwisepublic void reuse(int count)
Reuse this instance as a new barrier.
This method is a convenient way to prevent reallocation of a new
ThreadBarrier object and eventually the work of the garbage
collector to free the old one.
The count parameter is the same as in the
constructor.
IllegalStateException - if this instance si not released.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||