(1)自定义
ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
RejectedExecutionHandler handler)
(2)工厂类
Executors.newCachedThreadPool()
Executors.newFixedThreadPool(int)
Executors.newSingleThreadExecutor()

本文介绍了Java中线程池的创建方式,包括自定义线程池和使用Executors工具类提供的工厂方法。探讨了核心参数如核心线程数、最大线程数等设置的重要性。
170万+

被折叠的 条评论
为什么被折叠?



