参考文档:https://www.cnblogs.com/0201zcr/p/5995779.html
代码实列:
package com.examples.springboots.task; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** * @author: CSH * @description: 线程列表 * @create: 2020-04-22 09:51 **/ @Component public class BaseTask { /** * 秒 分 时 天 月 年 */ @Scheduled(cron = "0/5 * * * * *") public void scheduled() { System.out.println("=====>>>>>使用cron {}" + System.currentTimeMillis()); } @Scheduled(fixedRate = 5000) public void scheduled1() { System.out.println("=====>>>>>使用fixedRate{}" + System.currentTimeMillis()); } @Scheduled(fixedDelay = 5000) public void scheduled2() { System.out.println("=====>>>>>fixedDelay{}" + System.currentTimeMillis()); } }
原文:https://www.cnblogs.com/csh520mjy/p/12750342.html