List of utility methods to do ThreadPoolExecutor
ThreadPoolExecutor | getThreadPoolExecutor(int poolSize, int[] poolInfo) get Thread Pool Executor return new ThreadPoolExecutor(poolSize, poolInfo[0], poolInfo[1], TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(poolInfo[2])); |
String | getThreadPoolTrace(ThreadPoolExecutor threadpool) get Thread Pool Trace 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)); ... |
int | getWorkerCount(ThreadPoolExecutor workerExecutor) get Worker Count return Math.min(workerExecutor.getMaximumPoolSize(), DEFAULT_IO_THREADS);
|
RejectedExecutionHandler | parseRejectionPolicy(String rejection_policy) parse Rejection Policy if (rejection_policy == null) throw new IllegalArgumentException("rejection policy is null"); if (rejection_policy.equalsIgnoreCase("abort")) return new ThreadPoolExecutor.AbortPolicy(); if (rejection_policy.equalsIgnoreCase("discard")) return new ThreadPoolExecutor.DiscardPolicy(); if (rejection_policy.equalsIgnoreCase("discardoldest")) return new ThreadPoolExecutor.DiscardOldestPolicy(); ... |