Timer是一种定时器工具,用来在一个后台线程计划执行指定任务。它可以计划执行一个任务一次或反复多次。
TimerTask一个抽象类,它的子类代表一个可以被Timer计划的任务。

schedule的意思(时间表、进度表)
timer.schedule(new MyTask(event.getServletContext()), 0,
60*60*1000);

第一个参数"new
MyTask(event.getServletContext())":
是 TimerTask 类,在包:import java.util.TimerTask .使用者要继承该类,并实现 public
void run() 方法,因为 TimerTask 类实现了 Runnable 接口。

第二个参数"0"的意思是:(0就表示无延迟)
当你调用该方法后,该方法必然会调用 TimerTask 类 TimerTask 类 中的 run()
方法,这个参数就是这两者之间的差值,转换成汉语的意思就是说,用户调用 schedule() 方法后,要等待这么长的时间才可以第一次执行
run() 方法。

第三个参数"60*60*1000"的意思就是:
(单位是毫秒60*60*1000为一小时)
(单位是毫秒3*60*1000为三分钟)
第一次调用之后,从第二次开始每隔多长的时间调用一次 run() 方法

例子:

public Timer
createJobber(TimerTask o, String cronExpress) throws Exception
{
  Timer timer = new
Timer();
  timer.schedule(o, 0,
Integer.parseInt(cronExpress));
  return timer;
 }

Timer Schedule参数说明的更多相关文章

  1. Android定时器Timer.schedule

    Timer是一种定时器工具,用来在一个后台线程计划执行指定任务.它可以计划执行一个任务一次或反复多次.TimerTask一个抽象类,它的子类代表一个可以被Timer计划的任务. schedule的意思 ...

  2. timer.scheduleAtFixedRate和timer.schedule的实验

    基础代码: Calendar  currentTime = Calendar.getInstance(); currentTime.setTime(new Date()); int  currentH ...

  3. Java Timer, TimerTask, Timer.Schedule

    schedule的意思(时间表.进度表) timer.schedule(new TimerTask(){ void run()},0, 60*60*1000);timer.schedule(new M ...

  4. Android Timer schedule

    timer.schedule(new MyTask(),long time1,long timer2); 今天算是彻底的搞懂了这个以前让我为之头疼的方法. 以下我就重点介绍一下: 第一个參数.是 Ti ...

  5. java关于Timer schedule执行定时任务 !!!!!!!!!

    1.在应用开发中,经常需要一些周期性的操作,比如每5分钟执行某一操作等.对于这样的操作最方便.高效的实现方式就是使用java.util.Timer工具类. private java.util.Time ...

  6. 定时器new Timer().schedule()的使用

    Timer是一种工具,线程用其安排以后在后台线程中执行的任务.可安排任务执行一次,或者定期重复执行.实际上是个线程,定时调度所拥有的TimerTasks. TimerTask是一个抽象类,它的子类由 ...

  7. java关于Timer schedule执行定时任务 1、在应用开发中,经常需要一些周期性的操作,比如每5分钟执行某一操作等

    1.在应用开发中,经常需要一些周期性的操作,比如每5分钟执行某一操作等.对于这样的操作最方便.高效的实现方式就是使用java.util.Timer工具类. private java.util.Time ...

  8. 执行循环任务new Timer().schedule(new TimerTask(){},0,1000);

    package com.pingyijinren.test; import android.support.v7.app.AppCompatActivity; import android.os.Bu ...

  9. Spring Boot TImer Schedule Quartz

    Spring Boot 2.X(十二):定时任务-云栖社区-阿里云https://yq.aliyun.com/articles/723876?spm=a2c4e.11155472.0.0.2f8b3a ...

随机推荐

  1. 打开/查找xcode6的沙盒地目录

    用以下代码 打开沙盒目录 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainM ...

  2. SPOJ 7001. Visible Lattice Points (莫比乌斯反演)

    7001. Visible Lattice Points Problem code: VLATTICE Consider a N*N*N lattice. One corner is at (0,0, ...

  3. How to implement *All-Digital* analog-to-digital converters in FPGAs and ASICs

    When we engineers look at the complexity of system design these days, we are challenged with crammin ...

  4. mysql字符串比较

    select '123'B is TRUE;  1 SET @a='123';            select '123'is TRUE;      0 select cast('222' as ...

  5. 用SoapUI进行Webservice的性能压力测试

    转载:http://www.cnblogs.com/fnng/archive/2011/08/11/2135440.html 第一步: 新建一个项目:点击新建按钮就行了. 在打开的窗口中填写你项目名, ...

  6. PHP抓取页面中的邮箱

    <?php $url='http://www.cnblogs.com/tinyphp/p/3234926.html'; //当页已留邮箱 $content=file_get_contents($ ...

  7. Python学习(八)异常处理

    Python 异常处理 程序出错时,会抛出异常,这想必在之前学习过程中已经见过不少. 这边具体说明下Python 的标准异常.如何捕捉异常.抛出异常 以及自定义异常. python 标准异常 我们先来 ...

  8. poj 3264 Balanced Lineup 题解

    Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Subm ...

  9. rqnoj-208-奥运火炬到厦门-dp

    这道题目是把一个连续的串看成一个环. 那么除了原始的求最大字段和外. 还存在一种情况是前面的连续最大值,加上后面的连续最大值. #include<stdio.h> #include< ...

  10. eclipse启动tomcat, http://localhost:8080无法访问的解决方案

    问题:: tomcat在eclipse里面能正常启动,但在浏览器中访问http://localhost:8080/不能访问tomcat管理页面,且报404错误.同时其他项目页面也不能访问.访问的时候出 ...