Search code examples
javaspringspring-scheduled

How to prevent overlapping schedules in Spring?


@Scheduled(fixedDelay = 5000)
public void myJob() {
     Thread.sleep(12000);
}

How can I prevent this spring job from running if the previous routine is not yet finished?


Solution

  • With fixedDelay, the period is measured after the completion of job, so no worries.