Java examples for java.util.concurrent:ExecutorService
shut Down ExecutorService Synchronously
//package com.java2s; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; public class Main { public static void shutDownSynchronously(ExecutorService executorService) { if (executorService != null) { executorService.shutdown();/* ww w . j a va 2 s . c om*/ while (!executorService.isTerminated()) { try { executorService.awaitTermination(1, TimeUnit.MINUTES); } catch (InterruptedException e) { // Do not return on interrupts, but wait until all submitted tasks are completed. } } } } }