tags:

views:

240

answers:

3

Hi, I want a sample for thread pooling using Spring scheduler?

A: 

See the The Spring TaskExecutor abstraction, use the ThreadPoolTaskExecutor. It is configured as follows:

<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
  <property name="corePoolSize" value="5" />
  <property name="maxPoolSize" value="10" />
  <property name="queueCapacity" value="25" />
</bean>
David Rabinowitz
A: 

Your question is too vague to be sure what you want, but you could use the ScheduledExecutorFactoryBean to create a standard Java5 ScheduledExecutorService which has comprehensive scheduling functions.

skaffman
A: 

In Spring 3, the task namespace was added it contains what you need to setup a pooled TaskExecutor:

<task:executor id="executorWithCallerRunsPolicy"
           pool-size="5-25"
           queue-capacity="100"
           rejection-policy="CALLER_RUNS"/>

You can read http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/scheduling.html for details.

iwein