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

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

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

4条回答
  •  攒了一身酷
    2020-12-30 20:01

    Suggested here Why does ScheduledThreadPoolExecutor only accept a fixed number of threads? workaround:

    scheduledExecutor = new ScheduledThreadPoolExecutor(128); //no more than 128 threads
    scheduledExecutor.setKeepAliveTime(10, TimeUnit.SECONDS);
    scheduledExecutor.allowCoreThreadTimeOut(true);
    

提交回复
热议问题