Annotating a method with Spring's @Scheduled and specifying a fixed delay, like so:
@Scheduled(fixedRate = 5000)
public void test() {
log.info("The time is {}", Instant.now());
}
When I wake my computer after sleeping it, the task is run many times one immediately after another.
The time is 2020-07-14T08:00:30.358073400Z
The time is 2020-07-14T08:00:35.358969600Z
The time is 2020-07-14T08:00:40.358066100Z
...
The time is 2020-07-14T08:02:51.806689500Z
The time is 2020-07-14T08:02:51.806689500Z
The time is 2020-07-14T08:02:51.806689500Z
The time is 2020-07-14T08:02:51.806689500Z
The time is 2020-07-14T08:02:51.806689500Z
The time is 2020-07-14T08:02:51.807651500Z
The time is 2020-07-14T08:02:51.807651500Z
...
How can I make it run only once when the computer wakes up?