Spring @Scheduled timer accuracy

Viewed 2105

I'm using spring-boot @Scheduled annotation with fixedDelay in milliseconds as documented in javadoc:

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

Code:

@Scheduled(fixedDelay=1000)
public void task() {
    LOG.info("START: " + System.currentTimeInMillis());
    ....do some work here...
    LOG.info("END: " + System.currentTimeInMillis());
}

And sometimes I get such output that time between previous task end and next task starts is less than 1000ms for about 2-30 milliseconds.

Is it normal due to some granularity or why is it happening? Is there any guaranties about this delta value?

3 Answers
Related