Question

I need to describe how the @Scheduled annotation works.
There are three definition for Scheduled: fixedDelay, fixedRate and cron.
While the period of fixedDelay will be measured from the completion time of each preceding invocation, the period of fixedRate will be measured between the successive start times of each invocation.

But what about the cron period? How he will be measured?

Edit:
I know cron is not a period like the both fixed-information. I will describe my question with an example.

An example-method need 2 minutes to be finished. But with the @Scheduled-Annotation, I will let the method run every minute.

@Scheduled(fixedDelay = 1000)
public void exampleMethod(){}

fixedDelay will wait until the method is completed, and then he wait one minute. So the method will run every 3 Minutes.

@Scheduled(fixedRate = 1000)
public void exampleMethod(){}

fixedRate will wait one minute between the successive start times of each invocation. So the method will run every minute, doesn't matter if the method is completed or not.

@Scheduled(cron = "0 * * * * *")
public void exampleMethod(){}

So I set the cron to run every minute. Will the method be executed every minute or will cron wait until the method is completed?

Was it helpful?

Solution

Cron is a format that describes when a job should run. You can see a lot of good examples here

OTHER TIPS

Cron is not perod, a format similar records indicate periodicity in Linux scheduler Cron.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top