@Test public void testWait() { final AtomicInteger count = new AtomicInteger(); ExecutorService executor = Executors.newSingleThreadExecutor(); executor.submit(new Callable<Object>() { @Override public Void call() throws InterruptedException { Thread.sleep(500L); count.incrementAndGet(); return null; } }); ExecutorUtils.shutdownAndAwait(executor); assertEquals(1, count.get()); }
public static void shutdownAndAwait(ExecutorService executor) { if (!executor.isTerminated()) { if (!executor.isShutdown()) { executor.shutdown(); } await(executor); } }
ExecutorUtils { public static void shutdownAndAwait(ExecutorService executor) { if (!executor.isTerminated()) { if (!executor.isShutdown()) { executor.shutdown(); } await(executor); } } }
ExecutorUtils { public static void shutdownAndAwait(ExecutorService executor) { if (!executor.isTerminated()) { if (!executor.isShutdown()) { executor.shutdown(); } await(executor); } } private  ExecutorUtils(); }
ExecutorUtils { public static void shutdownAndAwait(ExecutorService executor) { if (!executor.isTerminated()) { if (!executor.isShutdown()) { executor.shutdown(); } await(executor); } } private  ExecutorUtils(); static int getParallelism(); static void shutdownNowAndAwait(ExecutorService executor); static void shutdownAndAwait(ExecutorService executor); static void checkExceptions(Iterable<Future<T>> futures); }
ExecutorUtils { public static void shutdownAndAwait(ExecutorService executor) { if (!executor.isTerminated()) { if (!executor.isShutdown()) { executor.shutdown(); } await(executor); } } private  ExecutorUtils(); static int getParallelism(); static void shutdownNowAndAwait(ExecutorService executor); static void shutdownAndAwait(ExecutorService executor); static void checkExceptions(Iterable<Future<T>> futures);  }