shut Down Executor Service And Await Termination - Java java.util.concurrent

Java examples for java.util.concurrent:Executors

Description

shut Down Executor Service And Await Termination

Demo Code


//package com.java2s;
import java.util.concurrent.ExecutorService;

import java.util.concurrent.TimeUnit;

public class Main {
    public static void shutDownExecutorServiceAndAwaitTermination(
            ExecutorService executorService, long timeout, TimeUnit timeUnit) {
        try {//from  w w  w.j a v  a2  s  . c  o  m
            executorService.shutdown();
            executorService.awaitTermination(timeout, timeUnit);
        } catch (InterruptedException e) {
            executorService.shutdownNow();
        }
    }
}

Related Tutorials