Java tutorial
//package com.java2s; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; public class Main { /** * Normal shutdown. * * @param pool the pool * @param timeout the timeout * @param timeUnit the time unit */ public static void normalShutdown(ExecutorService pool, int timeout, TimeUnit timeUnit) { try { pool.shutdownNow(); if (!pool.awaitTermination(timeout, timeUnit)) { System.err.println("Pool did not terminate"); } } catch (InterruptedException ie) { Thread.currentThread().interrupt(); } } }