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)

 

 

posted @ 2020-10-07 14:46  jentary  阅读(95)  评论(0编辑  收藏  举报