固定延遲

如果我們想要在執行之前定期執行一些程式碼,那麼我們應該使用固定延遲(以毫秒為單位):

@Component
public class MyScheduler{    
    
    @Scheduled(fixedDelay=5000)
    public void doSomething() {
        // this will execute periodically, after the one before finishes
    }
}