Repository navigation
thread_pool
Directory actions
More options
Directory actions
More options
thread_pool
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
newCachedThreadPool: 创建一个可缓存线程池,如果线程池长度超过处理需要,可灵活回收空闲线程,若无可回收,则新建线程。 内部线程数最大为支持Integer的最大值。 newFixedThreadPool: 创建一个定长线程池,可控制线程最大并发数,超出的线程会在队列中等待。 newScheduledThreadPool: 创建一个定长线程池,支持定时及周期性任务执行。 newSingleThreadExecutor: 创建一个单线程化的线程池,它只会用唯一的工作线程来执行任务,保证所有任务按照指定顺序(FIFO、LIFO) 执行。 总结: 线程池是对已有对象的复用,避免及时使用对象时可以直接从“池”中取,同时缩减了对象在创建与销毁上的时间 损耗。 参考:http://cuisuqiang.iteye.com/blog/2019372