zoukankan      html  css  js  c++  java
  • java中的定时器

    1:Timer 最底层定时器

    转载:https://blog.csdn.net/zbx931197485/article/details/78721847

    转载:https://blog.csdn.net/mazegong/article/details/77743805

    2:spring 框架中使用的其他三种定时工具

    转载:https://blog.csdn.net/lchq1995/article/details/78222528

    (1):spring task spring自带定时器使用实例:

          转载:https://www.cnblogs.com/Jason-Xiang/p/6593329.html

                   在applicationContext中配置:      

    <!-- 配置定时任务 -->
    <task:annotation-driven scheduler="qbScheduler" mode="proxy"/>
    <task:scheduler id="qbScheduler" pool-size="10"/>

    (2):

    package com.webservice.enquiryControler;


    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.scheduling.annotation.Scheduled;
    import org.springframework.stereotype.Component;

    import com.webservice.dao.enquiryDao.PriceDao;
    import com.webservice.util.TimeHelp;

    @Component
    public class SchedulerDemo {

    @Autowired
    PriceDao PriceDao;
    /*
    *
    * 定时任务*/
    @Scheduled(cron="0 */10 * * * ?")
    public void job(){

    String setTime=TimeHelp.SetCurrentTime();//比当前时间少11分钟

    String time = TimeHelp.getCurrentTime();//当前时间
    // System.out.println("***************************第"+count+"次定时任务正在执行***************************");
    // System.out.println("***************************开始时间:"+setTime+"****结束时间:"+time+"***************************");
    PriceDao.job(setTime,time);
    // System.out.println("***************************定时任务执行完成***************************");
    }
    }

  • 相关阅读:
    对流程和规范的思考
    我的一小时面试指南
    安全扫描工具nikto简单使用
    测试的角色
    测试的窘境
    关于重连测试的一点研究
    ETCD高可用特性学习
    Cgroup和Namespace在测试中的使用(下)
    单循环列表的删除前驱结点
    指针常量字符串
  • 原文地址:https://www.cnblogs.com/ConfidentLiu/p/9841920.html
Copyright © 2011-2022 走看看