I am using ConcurrentTaskExecutor
to run the multiple tasks at the same time. By default in spring, it is scoped as singleton.
Here my taskExecutor
is prototype and threadPoolExecutor
is no.t
When requested a new taskExecutor
is returned. My question is, since we are referring a threadPoolExecutor
from prototype, will threadPoolExecutor
be a new instance?
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ConcurrentTaskExecutor" scope="prototype">
<property name="concurrentExecutor" ref="threadPoolExecutor"/>
</bean>
<bean id="threadPoolExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="100" />
<property name="maxPoolSize" value="200" />
<property name="queueCapacity" value="1000" />
</bean>
The "prototype" keyword just means that each time you ask Spring for an instance, you will get a fresh instance. With the wiring you have, you are only asking once. So I expect that your taskExecutor bean will be a single instance.