Job not executing at fixed rate

81 views Asked by At

I have the following spring mvc configuration:

<task:scheduled-tasks scheduler="defaultScheduler">
   <task:scheduled ref="myTaskWorker" method="someMethod"
     fixed-rate="500" />
</task:scheduled-tasks>

When I execute the above it is not executed in every 500ms but only executed after the finishing of the previous one.

How can i resolve this?

1

There are 1 answers

0
java_dude On BEST ANSWER

The difference is about time rather than number of tasks. Fixed rate will keep track of time and spun new thread to match the fixed-time of 5 seconds. So in short, you would not have multiple threads as you are expecting.

In 15 seconds, there should be three executions. But if first task takes 10 seconds and second task takes 6 seconds then on 16th second, third task is going to start. And next task, would start on 20th second (fixed-rate), only if the third task is complete by then. Hope this makes sense.

Check out detailed answer here