oneCoderToRuleThemAll :
Is there a difference between configuring a Thread pool using the following configurations:
Executors.newFixedThreadPool(50);
versus doing:
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(50);
executor.setThreadNamePrefix("thread-pool");
executor.initialize();
I am not interested in configuring the thread pool during runtime (which is I think the main driver for using ThreadPoolTaskExecutor
).
Karol Dowbecki :
In your example Spring's ThreadPoolTaskExecutor
will create a ThreadPoolExecutor
with corePoolSize
of 50, maxPoolSize
of Integer.MAX_VALUE
and keepAlive
of 60 seconds.
Meanwhile Executors.newFixedThreadPool(50)
will set both corePoolSize
and maxPoolSize
to 50 and keepAlive
of 0 seconds (see Java source code).