现在的位置: 首页 > 综合 > 正文

Executors

2014年09月28日 ⁄ 综合 ⁄ 共 343字 ⁄ 字号 评论关闭

Executors  --- 负责生成各种连接池的实例          

 .newCachedThreadPool()  --- 有任务时才创建新线程,空闲线程保留60s。           

.newFixedThreadPool(int nThreads)  --- 创建固定数量的线程,空闲线程会一直保留。        

 .newScheduledThreadPool(int corePoolSize) --- 线程池按照时间计划执行任务,允许设置任务执行时  间。参数为最小线程数。繁忙时,可能创建更多线程。

 .newSingleThreadExecutor() --- 只建立一个工作线程,依次执行每个任务。
 .newSingleThreadScheduledExecutor() ----只一个线程,按时间计划执行任务。

抱歉!评论已关闭.