I have the following config for ThreadPoolTaskExecutor
<bean id="threadPoolTaskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="10" />
<property name="maxPoolSize" value="25" />
<property name="queueCapacity" value="30" />
</bean>
and I have 2 methods in my public class AdminService.
- void triggerJob();
- boolean executeSql(String sql);
How do i insert ThreadPoolTaskExecutor into triggerJob method so it creates new thread when executeSql is called inside first method.
Inside triggerjob i have loop that calls executeSql based on condition.
Do i need to create a private class that implements runnable so ThreadPoolTaskExecutor can execute this class or is it possible to create threads without runnable ?
My idea is something like this
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
void triggerJob(){
for( Object k:Objects){
if(k.equals(something){
//here new thread to be created somehow
threadPoolTaskExecutor.execute(executeSql(k.getSql())
}
}
}