| This class provides a counter that is used with a set of threaded operations.
It provides methods for incrementing and decrementing the counter. This
class is used when a thread is creating a number of instances of a class
extending the Operation abstract class to run on separate
threads, optionally under a time limit. The creating thread creates an
instance of this class, and passes that instance to the constructor for the
Operation subclass instances as it creates them. The
Operation constructor calls the incrememt method on this
class, automatically keeping a count of the number of threaded operations
that have been created. All of the operations are then started on separate
threads, and the creating thread calls the wait method on the
instance of this class, optionally with the desired timeout value. As the
Operation instances complete their processing, their
run methods call the decrement method on the instance
of this class. When the last operation completes, the decrement
method sets the counter to zero, and calls notify to end the
wait on the original thread. If the wait times out, the Operation
instances can be checked to determine which one(s) did not complete.
author: Sun Microsystems, Inc. |