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("***************************定时任务执行完成***************************");
    }
    }

  • 相关阅读:
    【codeforces 604D】Moodular Arithmetic
    【hdu 1846】Brave Game
    【hdu 2147】kiki's game
    【hdu 2188】选拔志愿者
    【hdu 2149】Public Sale
    【hdu 1847】Good Luck in CET-4 Everybody!
    【hdu 1849】Rabbit and Grass
    FreeBSD 内核中的SYSINIT分析【转】
    解决tomcat运行报错java.lang.UnsatisfiedLinkError: apache-tomcat-7.0.37in cnative-1.dll:Can load AMD 64
    菜单的事件推送
  • 原文地址:https://www.cnblogs.com/ConfidentLiu/p/9841920.html
Copyright © 2011-2022 走看看