Search code examples
javaspringparallel-processingscheduled-tasksjobs

@Scheduled behaviour when processing takes a long time. run in parallel?


I have a method with @Scheduled and this is set to run every 10 secs like so:

@Scheduled(fixedDelay = 1000 * 10)

If the method takes more than 10 secs to process, will another execution start in parallel? or will it wait for the current execution to finish?


Solution

  • It won't, because fixedDelay works like follows:

    Execute the annotated method with a fixed period in milliseconds between the end of the last invocation and the start of the next.

    Meaning that it waits for the function to complete and then waits n-milliseconds until the function is invoked again.