Here you can find the source of getThreadPoolTrace(ThreadPoolExecutor threadpool)
public static String getThreadPoolTrace(ThreadPoolExecutor threadpool)
//package com.java2s; //License from project: Apache License import java.util.concurrent.BlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; public class Main { public static String getThreadPoolTrace(ThreadPoolExecutor threadpool) { StringBuilder sb = new StringBuilder("thread pool: ["); if (threadpool != null) { sb.append("\nactiveCount:").append(threadpool.getActiveCount()); sb.append("\ncorePoolSize:").append(threadpool.getCorePoolSize()); sb.append("\nlargetPoolSize:").append(threadpool.getLargestPoolSize()); sb.append("\nmaximumPoolSize:").append(threadpool.getMaximumPoolSize()); sb.append("\ntaskCount").append(threadpool.getTaskCount()); sb.append("\nkeepAlive:").append(threadpool.getKeepAliveTime(TimeUnit.SECONDS)); BlockingQueue<?> queue = threadpool.getQueue(); if (queue != null) { sb.append("\nqueueSize:").append(queue.size()); }/*from w ww.jav a2s . c om*/ sb.append("\nstate:"); if (threadpool.isShutdown()) { sb.append("shutdown"); } else if (threadpool.isTerminated()) { sb.append("terminated"); } else if (threadpool.isTerminating()) { sb.append("terminating"); } else { sb.append("running"); } } else { sb.append("\nnull"); } sb.append("\n]"); return sb.toString(); } }