Java 8 CountDownLatch - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CountDownLatch class.

This code example shows how to use the following methods: countDown
        this.latch = new CountDownLatch(nonMasterNodes);
    } 
 
    @Override 
    public void onResponse(DiscoveryNode node) {
        latch.countDown();
    } 
 
    @Override 
    public void onFailure(DiscoveryNode node, Throwable t) {
        latch.countDown();
    } 
 
    @Override 
    public boolean awaitAllNodes(TimeValue timeout) throws InterruptedException {
        return latch.await(timeout.millis(), TimeUnit.MILLISECONDS);
    } 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: await
 
  public static void main(String[] args) throws InterruptedException {
    final Config config = ConfigFactory.parseString("akka.loglevel=DEBUG");
    final ActorSystem system = ActorSystem.create("EchoServer", config);
    try { 
      final CountDownLatch latch = new CountDownLatch(1);
      final ActorRef watcher = system.actorOf(Props.create(Watcher.class, latch), "watcher");
      final ActorRef nackServer = system.actorOf(Props.create(EchoManager.class, EchoHandler.class), "nack");
      final ActorRef ackServer = system.actorOf(Props.create(EchoManager.class, SimpleEchoHandler.class), "ack");
      watcher.tell(nackServer, ActorRef.noSender());
      watcher.tell(ackServer, ActorRef.noSender());
      latch.await(10, TimeUnit.MINUTES);
    } finally { 
      system.shutdown();
    } 
  } 
 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: await
        return shutDownLatch;
    } 
 
    public String getEchoMessage() {
        try { 
            messageLatch.await();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } 
        return echoMessage;
    } 
 
    public void setEchoMessage(final String echoMessage) {
        this.echoMessage = echoMessage;
        messageLatch.countDown();
    } 
 
} 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: await
     */ 
    public void run(final TestEJBRunnable task) throws Exception {
        final Principal principal = ejbContext.getCallerPrincipal();
        logger.debugf("Principal: %s", principal);
        task.setExpectedPrincipal(principal);
        final CountDownLatch latch = new CountDownLatch(1);
        final Runnable r = new Runnable() {
            @Override 
            public void run() { 
                task.run();
                latch.countDown();
            } 
        }; 
        managedThreadFactory.newThread(r).start();
        latch.await();
    } 
 
} 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: countDown
     * Stateless request scope 
     */ 
    @Test 
    public void testRequestScopeActive() throws Exception { 
        AsyncBean bean = lookup(AsyncBean.class);
        final CountDownLatch latch = new CountDownLatch(1);
 
        final Future<Integer> future = bean.testRequestScopeActive(latch);
        latch.countDown();
        int result = future.get();
        Assert.assertEquals(20, result);
    } 
 
    /** 
     * Stateful - void returned 
     */ 
    @Test 
    public void testVoidAsyncStatefulMethod() throws Exception { 
        AsyncStateful bean = lookup(AsyncStateful.class);
        Assert.assertFalse(AsyncStateful.voidMethodCalled);
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 CountDownLatch Questions & Answers:

See Code Examples for Java 8 CountDownLatch Methods: