ScheduledExecutorService consumes 100% CPU when corePoolSize = 0
3
1
I've ran into an interesting issue in production. I've had the following ScheduledThreadPool allocation code: ScheduledExecutorService executorService = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors() - 1); The thread pool was processing some tasks from the queue periodically. And everything was working fine till the moment when the service was deployed on a single core environment. Apparently, the line above converted to: ScheduledExecutorService executorService = Executors.newScheduledThreadPool(0); Since then, the JVM process CPU utilization was constantly around 100%. The moment I've changed Runtime.getRuntime().availableProcessors() - 1 to constant 1 the issue have gone. It took sometime to find out the root cause, but still I don't know ...