java--线程池

Executor executor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),
            Runtime.getRuntime().availableProcessors() * 2,
            5L, TimeUnit.SECONDS,
            new LinkedBlockingQueue<>(3),
            Executors.defaultThreadFactory(),
            new ThreadPoolExecutor.AbortPolicy());
    CompletionService<Object> completionSevice = new ExecutorCompletionService<Object>(executor);

(int corePoolSize, //线程池核心线程数量

int maximumPoolSize, //线程池最大线程数量

long keepAliveTime, //线程KeepAlive时间,当线程池数量超过核心线程数量以后,idle时间超过这个值的线程会被终止 TimeUnit unit,

//线程KeepAlive时间单位 BlockingQueue<Runnable> workQueue,

//任务队列 ThreadFactory threadFactory,

//创建线程的工厂对象 RejectedExecutionHandler handler)

原文地址:https://www.cnblogs.com/jentary/p/13777343.html