Search code examples
javaspringscheduled-tasksspring-annotations

@Scheduled annotation Spring


I am using Spring 3 annotation @Scheduled to create scheduled jobs on server. But i am confused about the parameters(cron, fixedDelay ,fixedRate) of @Scheduled annotation. Please explain the difference between these parameter and the situations in which I can use these parameters.


Solution

  • I believe the difference among different options are made clear here. It depends on how you need to execute the task:

    1. fixedRate makes Spring run the task on periodic intervals even if the last invocation may be still running.
    2. fixedDelay specifically controls the next execution time when the last execution finishes.
    3. cron is a feature originating from Unix cron utility and has various options based on your requirements.