Example usage for java.util.concurrent ThreadPoolExecutor toString

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

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string identifying this pool, as well as its state, including indications of run state and estimated worker and task counts.

Usage

From source file:eu.artofcoding.beetlejuice.spring.SpringContextHelper.java

private void stopExecutors() {
    ThreadPoolTaskExecutor springTaskExecutor = applicationContext.getBean("taskExecutor",
            ThreadPoolTaskExecutor.class);
    ThreadPoolExecutor springExecutor = springTaskExecutor.getThreadPoolExecutor();
    springExecutor.shutdownNow();//from   w  w  w .  jav a  2 s.  com
    Map<String, ThreadPoolTaskExecutor> map = applicationContext.getBeansOfType(ThreadPoolTaskExecutor.class);
    ThreadPoolTaskExecutor t = null;
    for (String key : map.keySet()) {
        t = map.get(key);
        final ThreadPoolExecutor executor = t.getThreadPoolExecutor();
        executor.shutdownNow();
        logger.info(
                String.format("%s: active after shutdown: %d", executor.toString(), executor.getActiveCount()));
        logger.info(String.format("%s: completed after shutdown: %d", executor.toString(),
                executor.getCompletedTaskCount()));
    }
}