CountDownLatch


CountDownLatch java.util.concurrent

Java 5.0

This class synchronizes threads. All threads that call await( ) block until the countDown( ) method is invoked a specified number of times. The required number of calls is specified when the CountDownLatch is created. Once countDown( ) has been called the required number of times, all threads blocked in await( ) are allowed to resume, and any subsequent calls to await( ) do not block. getCount( ) returns the number of calls to countDown( ) that must still be made before the threads blocked in await( ) can resume. Note that there is no way to reset the count. Once a CountDownLatch has "latched," it remains in that state forever. Create a new CountDownLatch if you need to synchronize another group of threads. Contrast this class with CyclicBarrier .

 public class  CountDownLatch  {  // Public Constructors  public  CountDownLatch  (int  count  );  // Public Instance Methods  public void  await  ( ) throws InterruptedException;        public boolean  await  (long  timeout  , TimeUnit  unit  ) throws InterruptedException;        public void  countDown  ( );        public long  getCount  ( );  // Public Methods Overriding Object  public String  toString  ( );   } 



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net