Java Utililty Methods ThreadPoolExecutor

List of utility methods to do ThreadPoolExecutor

Description

The list of methods to do ThreadPoolExecutor are organized into topic(s).

Method

ThreadPoolExecutorgetThreadPoolExecutor(int poolSize, int[] poolInfo)
get Thread Pool Executor
return new ThreadPoolExecutor(poolSize, poolInfo[0], poolInfo[1], TimeUnit.SECONDS,
        new ArrayBlockingQueue<Runnable>(poolInfo[2]));
StringgetThreadPoolTrace(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));
...
intgetWorkerCount(ThreadPoolExecutor workerExecutor)
get Worker Count
return Math.min(workerExecutor.getMaximumPoolSize(), DEFAULT_IO_THREADS);
RejectedExecutionHandlerparseRejectionPolicy(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();
...