Package java.util.concurrent

Examples of java.util.concurrent.ScheduledExecutorService.awaitTermination()


        handle.cancel(true);
        /* schedule a last update */
        scheduler.schedule(new BSStatusCollector(), 0, TimeUnit.SECONDS);
        scheduler.shutdownNow();
        try {
          scheduler.awaitTermination(10, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
          LOG.info("Interruped while waiting for scheduler");
        }
        process.destroy();
      }
View Full Code Here


    factory.shutdown(factoryShutdown);
    factoryShutdown.get(30, TimeUnit.SECONDS);

    Assert.assertTrue(boss.awaitTermination(30, TimeUnit.SECONDS), "Failed to shut down boss");
    Assert.assertTrue(worker.awaitTermination(30, TimeUnit.SECONDS), "Failed to shut down worker");
    Assert.assertTrue(scheduler.awaitTermination(30, TimeUnit.SECONDS), "Failed to shut down scheduler");
  }

  @Test
  public void testShutdownBeforeClients() throws ExecutionException, TimeoutException, InterruptedException
  {
View Full Code Here

    factoryShutdown.get(30, TimeUnit.SECONDS);

    Assert.assertTrue(boss.awaitTermination(30, TimeUnit.SECONDS), "Failed to shut down boss");
    Assert.assertTrue(worker.awaitTermination(30, TimeUnit.SECONDS), "Failed to shut down worker");
    Assert.assertTrue(scheduler.awaitTermination(30, TimeUnit.SECONDS), "Failed to shut down scheduler");
  }

  @Test
  public void testGetRawClient()
  {
View Full Code Here

    factoryShutdown.get(30, TimeUnit.SECONDS);

    Assert.assertTrue(boss.awaitTermination(30, TimeUnit.SECONDS), "Failed to shut down boss");
    Assert.assertTrue(worker.awaitTermination(30, TimeUnit.SECONDS), "Failed to shut down worker");
    Assert.assertTrue(scheduler.awaitTermination(30, TimeUnit.SECONDS), "Failed to shut down scheduler");
  }

  @Test
  public void testShutdownNoTimeout() throws ExecutionException, TimeoutException, InterruptedException
  {
View Full Code Here

    clientShutdown.get(60, TimeUnit.SECONDS);
    factoryShutdown.get(60, TimeUnit.SECONDS);

    Assert.assertTrue(boss.awaitTermination(60, TimeUnit.SECONDS));
    Assert.assertTrue(worker.awaitTermination(60, TimeUnit.SECONDS));
    Assert.assertTrue(scheduler.awaitTermination(60, TimeUnit.SECONDS));
  }

  /**
   * Tests that even when the factory is shutdown with a long timeout, it does not occupy
   * any executors with tasks that might prevent them shutting down properly.
View Full Code Here

    FutureCallback<None> callback = new FutureCallback<None>();
    factory.shutdown(callback, 60, TimeUnit.MINUTES);
    callback.get(60, TimeUnit.SECONDS);
    scheduler.shutdown();
    channelFactory.releaseExternalResources();
    Assert.assertTrue(scheduler.awaitTermination(60, TimeUnit.SECONDS));
    Assert.assertTrue(boss.awaitTermination(60, TimeUnit.SECONDS));
    Assert.assertTrue(worker.awaitTermination(60, TimeUnit.SECONDS));
  }

  @Test
View Full Code Here

    public void stop() {
        final ScheduledExecutorService scheduler = this.scheduler.get();
        if (scheduler != null && this.scheduler.compareAndSet(scheduler, null)) {
            scheduler.shutdown();
            try {
                if (!scheduler.awaitTermination(10000, MILLISECONDS)) {
                    java.util.logging.Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Pool scheduler termination timeout expired");
                }
            } catch (InterruptedException e) {
                //Ignore
            }
View Full Code Here

      public void run() {
        System.out.println("hashes: " + counter.get());
      }
    }, 0, 1000, TimeUnit.MILLISECONDS);

    scheduledExecutorService.awaitTermination(30, TimeUnit.SECONDS);
  }
}
View Full Code Here

        // Shut down the executor service
        ScheduledExecutorService executor = context.getExecutor();
        executor.shutdown();
        try {
            // Wait for all remaining background threads to terminate
            if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
                log.warn("Attempting to forcibly shutdown runaway threads");
                executor.shutdownNow();
            }
        } catch (InterruptedException e) {
            log.warn("Interrupted while waiting for background threads", e);
View Full Code Here

      pool1.shutdown();
      pool2.shutdown();

      pool1.awaitTermination(1, TimeUnit.SECONDS);
      pool2.awaitTermination(1, TimeUnit.SECONDS);
   }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.