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?
source to share
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"
.
source to share