Why is there no scheduled cached thread pool provided by the Java Executors class?

前端 未结 4 486
庸人自扰
庸人自扰 2020-12-30 19:20

Executors provides newCachedThreadPool() and newScheduledThreadPool(), but not newCachedScheduledThreadPool(), what gives

4条回答
  •  长情又很酷
    2020-12-30 19:57

    By design the ScheduledThreadPoolExecutor is a fixed size. You can use a single threaded version that submits to a normal ExecutorService for performing the task. This event thread + worker pool is fairly ease to coordinate and the flexibility makes up for the dedicated thread. I've used this in the past to replace TimerTasks and other non-critical tasks to utilize a common executor as a system-wide pool.

提交回复
热议问题