Grzegorz Grzybek Peter Runge Thank you both for your valuable input. When I had made the change, I remember having testing for this issue. However, I probably tested using ThreadPoolExecutor which has a dynamic thread pool where as ScheduledThreadPoolExecutor has a fixed size pool. The javadoc of ScheduledThreadPoolExecutor state:
While this class inherits from ThreadPoolExecutor, 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 to maximumPoolSize 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.
The bug actually stems from my confusion between ScheduledThreadPoolExecutor and ThreadPoolExecutor. |