ScheduledThreadPoolExecutor

1、

2、ScheduledThreadPoolExecutor和Timer类似,可以设定一段时间delay之后或者按照一定的rate来执行任务。

3、ScheduledThreadPoolExecutor继承自ThreadPoolExecutor,但是ThreadPoolExecutor的一些API对ScheduledThreadPoolExecutor是无效的,因为ScheduledThreadPoolExecutor本质上是一个只有coreSize大小的而且BlockingQueue为inbound的一个线程池。

a few of the inherited tuning methods are not useful for it. In particular, because it acts as a fixed-sized pool using corePoolSize threads and an unbounded queue, adjustments tomaximumPoolSize have no useful effect. Additionally, it is almost never a good idea to set corePoolSize to zero or use allowCoreThreadTimeOut because this may leave the pool without threads to handle tasks once they become eligible to run.

原文地址:https://www.cnblogs.com/YDDMAX/p/5208497.html