Package com.clarkware.junitperf
Class ThreadBarrier
- java.lang.Object
-
- com.clarkware.junitperf.ThreadBarrier
-
public class ThreadBarrier extends java.lang.ObjectTheThreadBarrierclass provides a callback method for threads to signal their completion.- Author:
- Mike Clark, Clarkware Consulting, Inc.
-
-
Field Summary
Fields Modifier and Type Field Description intdispatchedCountintreturnedCount
-
Constructor Summary
Constructors Constructor Description ThreadBarrier(int numDispatched)Constructs aThreadBarrierwith the specified number of threads to wait for.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancelThreads(int threadCount)Cancels the specified number of threads.booleanisReached()Determines whether the thread barrier has been reached - when all dispatched threads have returned.voidonCompletion(java.lang.Thread t)Called when the specified thread is complete.
-
-
-
Method Detail
-
onCompletion
public void onCompletion(java.lang.Thread t)
Called when the specified thread is complete.- Parameters:
t- Completed thread.
-
isReached
public boolean isReached()
Determines whether the thread barrier has been reached - when all dispatched threads have returned.- Returns:
trueif the barrier has been reached;falseotherwise.
-
cancelThreads
public void cancelThreads(int threadCount)
Cancels the specified number of threads.- Parameters:
threadCount- Number of threads to cancel.
-
-