Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





#Java - Code Snippets for '#Java.util.concurrent.CountDownLatch' - 2 code snippet(s) found

 Sample 1. RabbitMQ message receiver

import java.util.concurrent.CountDownLatch;

public class Receiver {

   private CountDownLatch latch = new CountDownLatch(1);

   public void receiveMessage(String message) {
      latch.countDown();
   }

   public CountDownLatch getLatch() {
      return latch;
   }

}

   Like      Feedback     Spring AMQP  Rabbit MQ  RabbitMQ


 Sample 2. Code Sample / Example / Snippet of java.util.concurrent.CountDownLatch

    public void testTooLongTask() throws Exception {

final CountDownLatch latch = new CountDownLatch(5);



Executer executer = new Executer(new Runnable() {

public void run() {

try {

Thread.sleep(20);

latch.countDown();

}

catch (InterruptedException e) {

e.printStackTrace();

}

}

});

executer.start(10);

assert latch.await(1, TimeUnit.SECONDS);

}


   Like      Feedback      java.util.concurrent.CountDownLatch



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner