com.clarkware.junitperf
Class ThreadBarrier

java.lang.Object
  extended bycom.clarkware.junitperf.ThreadBarrier

public class ThreadBarrier
extends java.lang.Object

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

Author:
Mike Clark, Clarkware Consulting, Inc.

Field Summary
 int _dispatchedCount
           
 int _returnedCount
           
 
Constructor Summary
ThreadBarrier(int numDispatched)
          Constructs a ThreadBarrier with the specified number of threads to wait for.
 
Method Summary
 void cancelThreads(int threadCount)
          Cancels the specified number of threads.
 boolean isReached()
          Determines whether the thread barrier has been reached - when all dispatched threads have returned.
 void onCompletion(java.lang.Thread t)
          Called when the specified thread is complete.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_returnedCount

public int _returnedCount

_dispatchedCount

public final int _dispatchedCount
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

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:
true if the barrier has been reached; false otherwise.

cancelThreads

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

Parameters:
threadCount - Number of threads to cancel.


Copyright © 2001-2002 Clarkware Consulting, Inc. All Rights Reserved.