@Test(timeout=10000) public void testAwaitTerminationWithNullService() throws Exception { assertTrue(ThreadPoolUtils.awaitTermination(null, 1000)); }
public static boolean awaitTermination(ExecutorService executorService, long shutdownAwaitTermination) throws InterruptedException { if (executorService == null) { return true; } StopWatch watch = new StopWatch(); long interval = Math.min(2000, shutdownAwaitTermination); boolean done = false; while (!done && interval > 0) { if (executorService.awaitTermination(interval, TimeUnit.MILLISECONDS)) { done = true; } else { LOG.debug("Waited {} for ExecutorService: {} to terminate...", TimeUtils.printDuration(watch.taken()), executorService); interval = Math.min(2000, shutdownAwaitTermination - watch.taken()); } } return done; }
ThreadPoolUtils { public static boolean awaitTermination(ExecutorService executorService, long shutdownAwaitTermination) throws InterruptedException { if (executorService == null) { return true; } StopWatch watch = new StopWatch(); long interval = Math.min(2000, shutdownAwaitTermination); boolean done = false; while (!done && interval > 0) { if (executorService.awaitTermination(interval, TimeUnit.MILLISECONDS)) { done = true; } else { LOG.debug("Waited {} for ExecutorService: {} to terminate...", TimeUtils.printDuration(watch.taken()), executorService); interval = Math.min(2000, shutdownAwaitTermination - watch.taken()); } } return done; } }
ThreadPoolUtils { public static boolean awaitTermination(ExecutorService executorService, long shutdownAwaitTermination) throws InterruptedException { if (executorService == null) { return true; } StopWatch watch = new StopWatch(); long interval = Math.min(2000, shutdownAwaitTermination); boolean done = false; while (!done && interval > 0) { if (executorService.awaitTermination(interval, TimeUnit.MILLISECONDS)) { done = true; } else { LOG.debug("Waited {} for ExecutorService: {} to terminate...", TimeUtils.printDuration(watch.taken()), executorService); interval = Math.min(2000, shutdownAwaitTermination - watch.taken()); } } return done; }  }
ThreadPoolUtils { public static boolean awaitTermination(ExecutorService executorService, long shutdownAwaitTermination) throws InterruptedException { if (executorService == null) { return true; } StopWatch watch = new StopWatch(); long interval = Math.min(2000, shutdownAwaitTermination); boolean done = false; while (!done && interval > 0) { if (executorService.awaitTermination(interval, TimeUnit.MILLISECONDS)) { done = true; } else { LOG.debug("Waited {} for ExecutorService: {} to terminate...", TimeUtils.printDuration(watch.taken()), executorService); interval = Math.min(2000, shutdownAwaitTermination - watch.taken()); } } return done; }  static void shutdown(ExecutorService executorService); static List<Runnable> shutdownNow(ExecutorService executorService); static void shutdownGraceful(ExecutorService executorService); static void shutdownGraceful(ExecutorService executorService, long shutdownAwaitTermination); static boolean awaitTermination(ExecutorService executorService, long shutdownAwaitTermination); }
ThreadPoolUtils { public static boolean awaitTermination(ExecutorService executorService, long shutdownAwaitTermination) throws InterruptedException { if (executorService == null) { return true; } StopWatch watch = new StopWatch(); long interval = Math.min(2000, shutdownAwaitTermination); boolean done = false; while (!done && interval > 0) { if (executorService.awaitTermination(interval, TimeUnit.MILLISECONDS)) { done = true; } else { LOG.debug("Waited {} for ExecutorService: {} to terminate...", TimeUtils.printDuration(watch.taken()), executorService); interval = Math.min(2000, shutdownAwaitTermination - watch.taken()); } } return done; }  static void shutdown(ExecutorService executorService); static List<Runnable> shutdownNow(ExecutorService executorService); static void shutdownGraceful(ExecutorService executorService); static void shutdownGraceful(ExecutorService executorService, long shutdownAwaitTermination); static boolean awaitTermination(ExecutorService executorService, long shutdownAwaitTermination); static final long DEFAULT_SHUTDOWN_AWAIT_TERMINATION; }