Class ThreadBarrier
java.lang.Object
com.clarkware.junitperf.ThreadBarrier
The
ThreadBarrier class provides a callback
method for threads to signal their completion.- Author:
- Mike Clark, Clarkware Consulting, Inc.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionThreadBarrier(int numDispatched) Constructs aThreadBarrierwith the specified number of threads to wait for. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelThreads(int threadCount) Cancels the specified number of threads.booleanDetermines whether the thread barrier has been reached - when all dispatched threads have returned.voidCalled when the specified thread is complete.
-
Field Details
-
returnedCount
public int returnedCount -
dispatchedCount
public final int dispatchedCount
-
-
Constructor Details
-
ThreadBarrier
public ThreadBarrier(int numDispatched) Constructs aThreadBarrierwith the specified number of threads to wait for.- Parameters:
numDispatched- Number of threads dispatched.
-
-
Method Details
-
onCompletion
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.
-