Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.concurrent.TimeUnit;

public class Main {
    public static void shutdown(final ExecutorService executorService) {
        executorService.shutdown();
        try {
            int timeToWait = 30;
            if (!executorService.awaitTermination(timeToWait, TimeUnit.SECONDS)) {
                List<Runnable> executionList = executorService.shutdownNow();
                for (Runnable runnable : executionList) {
                    System.out.println("Trying to shutdown task: " + runnable);
                }
            }
            if (!executorService.awaitTermination(timeToWait, TimeUnit.SECONDS)) {
            }
        } catch (InterruptedException ex) {
            executorService.shutdownNow();
            Thread.currentThread().interrupt();
        }
    }
}