Search code examples
javaspringexecutorservicethreadpoolexecutor

ThreadPoolExecutorFactoryBean in tomcat


I am trying to use ThreadPoolExecutorFactoryBean in tomcat, does this bean interfere with tomcat threads?

<bean id="executorService" class="org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean">
    <property name="corePoolSize" value="40" />
    <property name="maxPoolSize" value="40" />
    <property name="allowCoreThreadTimeOut" value="true" />
    <property name="keepAliveSeconds" value="5" />
</bean>

Solution

  • The javadoc of ThreadPoolExecutorFactoryBean states

    JavaBean that allows for configuring a java.util.concurrent.ThreadPoolExecutor in bean style [...]

    In other words, once Spring processes the bean definition, it will create a ThreadPoolExecutor with the properties you provided. This object will create a standalone pool of threads. These threads are unrelated to any other threads in your application.

    They will interfere with other threads in the sense that the thread scheduler will have more threads to share time slices with. That's it.

    We have started to see a weird issue in production where jdbc connection pool is running out of the connections after this change..i am not exactly sure if this is causing it though..want to be sure this is somehow not causing it...

    Unless you are doing somehow sharing the connections between these threads and others, I can't imagine that thread pool causing the behavior you describe.