首页 > 其他 > 详细

pringboot实现定时任务Schedule

时间:2020-04-22 10:43:22      阅读:75      评论:0      收藏:0      [点我收藏+]

参考文档: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());
    }
}

 

pringboot实现定时任务Schedule

原文:https://www.cnblogs.com/csh520mjy/p/12750342.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!