ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CountDownLatch.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CountDownLatch.java (file contents):
Revision 1.4 by brian, Mon Jun 23 02:26:16 2003 UTC vs.
Revision 1.5 by dl, Tue Jun 24 14:34:47 2003 UTC

# Line 20 | Line 20 | package java.util.concurrent;
20   * a {@link CyclicBarrier}.
21   *
22   * <p>A <tt>CountDownLatch</tt> is a versatile synchronization tool
23 < * and can be used for a number of purposes.
24 < * A <tt>CountDownLatch</tt> initialized with a count of one serves as a simple on/off
25 < * latch, or gate: all threads invoking {@link #await} wait at the gate until
26 < * it is opened by a thread invoking {@link #countDown}.
27 < * A <tt>CountDownLatch</tt> initialized to <em>N</em> can be used to make
28 < * one thread wait until <em>N</em> threads have completed some action, or some
29 < * action has been completed N times.
30 < * <p>A useful property of a <tt>CountDownLatch</tt> is that it doesn't
31 < * require that threads calling <tt>countDown</tt> wait for the count to reach zero
32 < * before proceeding, it simply
33 < * prevents any thread from proceeding past the {@link #await wait} until
34 < * all threads could pass.
23 > * and can be used for a number of purposes.  A
24 > * <tt>CountDownLatch</tt> initialized with a count of one serves as a
25 > * simple on/off latch, or gate: all threads invoking {@link #await}
26 > * wait at the gate until it is opened by a thread invoking {@link
27 > * #countDown}.  A <tt>CountDownLatch</tt> initialized to <em>N</em>
28 > * can be used to make one thread wait until <em>N</em> threads have
29 > * completed some action, or some action has been completed N times.
30 > * <p>A useful property of a <tt>CountDownLatch</tt> is that it
31 > * doesn't require that threads calling <tt>countDown</tt> wait for
32 > * the count to reach zero before proceeding, it simply prevents any
33 > * thread from proceeding past the {@link #await wait} until all
34 > * threads could pass.
35   *
36   * <p><b>Sample usage:</b> Here is a pair of classes in which a group
37   * of worker threads use two countdown latches:
# Line 79 | Line 79 | package java.util.concurrent;
79   *
80   * </pre>
81   *
82 < * <p>Another typical usage would be to divide a problem into N parts, describe each part
83 < * with a Runnable that executes that portion and counts down on the latch, and queue all
84 < * the Runnables to an Executor.  When all sub-parts are complete, the coordinating thread
82 > * <p>Another typical usage would be to divide a problem into N parts,
83 > * describe each part with a Runnable that executes that portion and
84 > * counts down on the latch, and queue all the Runnables to an
85 > * Executor.  When all sub-parts are complete, the coordinating thread
86   * will be able to pass through await.
87   *
88   * <pre>
# Line 121 | Line 122 | package java.util.concurrent;
122   * @spec JSR-166
123   * @revised $Date$
124   * @editor $Author$
125 + * @author Doug Lea
126   */
127   public class CountDownLatch {
128      private final ReentrantLock lock = new ReentrantLock();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines