Here you can find the source of createThreadPoolExecutor(final int queueSize, final String threadName)
public static ThreadPoolExecutor createThreadPoolExecutor(final int queueSize, final String threadName)
//package com.java2s; //License from project: Apache License import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; public class Main { public static ThreadPoolExecutor createThreadPoolExecutor(final int queueSize, final String threadName) { ThreadFactory threadFactory = new ThreadFactory() { public Thread newThread(Runnable r) { Thread t = new Thread(r, threadName); t.setDaemon(true);//from w w w .j a v a2 s . c o m return t; } }; int processors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2); LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(queueSize); ThreadPoolExecutor executor = new ThreadPoolExecutor(processors, processors, 2, TimeUnit.SECONDS, queue, threadFactory, new ThreadPoolExecutor.DiscardPolicy()); executor.allowCoreThreadTimeOut(true); return executor; } }