Scheduling java.util.concurrent.Callable through Spring means

Spring org.springframework.scheduling.TaskScheduler

differs from the JDK java.util.concurrent.ScheduledExecutorService

in that it doesn't allow for java.util.concurrent.Callable

fixed latency scheduling (it can just schedule java.lang.Runnable

s).

Is there a Spring based alternative (which automatically shuts down when the context is destroyed) that supports scheduling Callable

s?

0


source to share


1 answer


If you only need to turn off, use destroy-method

:

<bean id="threadPool" class="java.util.concurrent.Executors" 
      factory-method="newFixedThreadPool"
      destroy-method="shutdown">
    <constructor-arg type="int" value="6"/>
</bean>

      



Works well for us.

PS. You may need to use factory-method="newScheduledThreadPool"

.

+2


source







All Articles