I am using spring 4.0.2 The @scheduled annotation is not working properly in the given interval. This is my code
@Scheduled(initialDelay=60*1000, fixedRate=60*1000) //60secs
private void method() {
System.out.println("Scheduled Task Running @"+new Date());
}
And this is my output
Scheduled Task Running @Thu Sep 21 12:00:51 IST 2017
Scheduled Task Running @Thu Sep 21 12:00:57 IST 2017
Scheduled Task Running @Thu Sep 21 12:01:51 IST 2017
Scheduled Task Running @Thu Sep 21 12:01:57 IST 2017
Scheduled Task Running @Thu Sep 21 12:02:51 IST 2017
Scheduled Task Running @Thu Sep 21 12:02:57 IST 2017
My requirement is for every one minute the method should be invoked. Its working, but after 6 secs of method invocation it's invoking the method again. So the method was invoked twice in a minute. Can any one tell why its behaving like this? How can I solve this?
Thanks,