spring task scheduler pool size

<task:scheduler id="myScheduler" pool-size="15" />

<task:scheduler/> is a wrapper around ScheduledThreadPoolExecutor extending ThreadPoolExecutor. JavaDoc for the latter says:

even core threads are initially created and started only when new tasks arrive

Secondly scheduled tasks (this is a Java feature, not Spring’s) do not run concurrently, even if they take longer time than repeat interval. They simply wait. So you don’t have 15 events waiting in the queue, you have 15 executions that are late and wait for that single thread. No need to create another one because next execution has to wait for the previous one to finish. Again, this is how Java scheduling framework works.

Leave a comment