Example usage for java.util.concurrent ExecutorService toString

List of usage examples for java.util.concurrent ExecutorService toString

Introduction

In this page you can find the example usage for java.util.concurrent ExecutorService toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.amazonaws.services.cloudtrail.processinglibrary.AWSCloudTrailProcessingExecutor.java

/**
 * Helper function to gracefully stop an {@link ExecutorService}.
 *
 * @param threadPool the thread pool to stop.
 *//*from ww  w . ja v a 2  s .co m*/
private void stopThreadPool(ExecutorService threadPool) {
    LibraryUtils.checkCondition(threadPool == null, "Thread pool is null when calling stop");

    if (threadPool.isShutdown()) {
        logger.debug(threadPool.toString() + " is already stopped.");

    } else {

        logger.debug(threadPool.toString() + " is about to shutdown.");
        threadPool.shutdown(); // Shutdown thread pool

        try { // Wait for shutdown
            threadPool.awaitTermination(this.config.getThreadTerminationDelaySeconds(), TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            logger.debug("Wait thread pool termination is interrupted.");
        }

        if (!threadPool.isShutdown()) { // ShutdownNow after waiting
            logger.debug(threadPool.toString() + " is force to shutdown now.");
            threadPool.shutdownNow();
        }

        logger.debug(threadPool.toString() + " is stopped.");
    }
}