Spring version of java.util.concurrent.ScheduledThreadPoolExecutor
I want to run some threads simultaneously which executes a given runnable task at regular intervals. Each thread will have its own instance of Runnable
task.
I found out java.util.concurrent.ScheduledThreadPoolExecutor
which seems to fulfill my requirement.
Does there exist any Spring class which provides same functionality? and if 开发者_JAVA技巧yes, which one is better is to use.
Thanks
Jitendra
http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.html is what I wanted. It is a wrapper around java.util.concurrent.ScheduledThreadPoolExecutor
.
You probably want to have a look at Spring's org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
. The reference documentation has a good example.
Spring Batch allows for invoking a method according to a cron string.
Spring Quartz schedular provides the java.util.concurrent.ScheduledThreadPoolExecutor
functionality you are looking for. Refer to
22.2.2. Using the MethodInvokingJobDetailFactoryBean and 22.2.3. Wiring up jobs using triggers and the SchedulerFactoryBean for details @
Chapter 22. Scheduling jobs using Quartz or Timer. We used in one of the project to schedule jobs at fixed intervals using cron expression. You can also restrict concurrent initiation of a Job if the previous job is still running.
精彩评论