com.clarkware.junitperf

Class ThreadBarrier

public class ThreadBarrier extends Object

The ThreadBarrier class provides a callback method for threads to signal their completion.

Author: Mike Clark Clarkware Consulting, Inc.

Field Summary
intdispatchedCount
intreturnedCount
Constructor Summary
ThreadBarrier(int numDispatched)
Constructs a ThreadBarrier with the specified number of threads to wait for.
Method Summary
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(Thread t)
Called when the specified thread is complete.

Field Detail

dispatchedCount

public final int dispatchedCount

returnedCount

public int returnedCount

Constructor Detail

ThreadBarrier

public ThreadBarrier(int numDispatched)
Constructs a ThreadBarrier with the specified number of threads to wait for.

Parameters: numDispatched Number of threads dispatched.

Method Detail

cancelThreads

public void cancelThreads(int threadCount)
Cancels the specified number of threads.

Parameters: threadCount Number of threads to cancel.

isReached

public boolean isReached()
Determines whether the thread barrier has been reached - when all dispatched threads have returned.

Returns: true if the barrier has been reached; false otherwise.

onCompletion

public void onCompletion(Thread t)
Called when the specified thread is complete.

Parameters: t Completed thread.

Copyright B) 1999-2005 Clarkware Consulting, Inc.