看api的说明 * <p>Corresponding to each <tt>Timer</tt> object is a single background * thread that is used to execute all of the timer's tasks, sequentially. * Timer tasks should complete quickly. If a timer task takes excessive time * to complete, it "hogs" the timer's task execution thread. This can, in * turn, delay the execution of subsequent tasks, which may "bunch up" and * execute in rapid succession when (and if) the offending task finally * completes. * Timer使用单线程来跑所有定时任务,按顺序地。如果有一个任务用了太久的执行时间,则它会“hog”住整个执行线程。这将会延迟后续的任务执行; 那么对于一次性的任务,他们虽然会被前面的任务拖延时间,但是终归是要执行一次的。 对于定时的循环的任务,则会给人一种丢失了前一(几)轮运行的感觉。
* <p>Corresponding to each <tt>Timer</tt> object is a single background
* thread that is used to execute all of the timer's tasks, sequentially.
* Timer tasks should complete quickly. If a timer task takes excessive time
* to complete, it "hogs" the timer's task execution thread. This can, in
* turn, delay the execution of subsequent tasks, which may "bunch up" and
* execute in rapid succession when (and if) the offending task finally
* completes.
*
Timer使用单线程来跑所有定时任务,按顺序地。如果有一个任务用了太久的执行时间,则它会“hog”住整个执行线程。这将会延迟后续的任务执行;
那么对于一次性的任务,他们虽然会被前面的任务拖延时间,但是终归是要执行一次的。
对于定时的循环的任务,则会给人一种丢失了前一(几)轮运行的感觉。
嗯,不过我说的不是定时任务,就是执行一次的任务,delay≈0