计时器与ScheduledExecutorService调度 [英] Timer vs. ScheduledExecutorService scheduling
本文介绍了计时器与ScheduledExecutorService调度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ScheduledExecutorService 可以直接替换Timer 类,已经在众多 StackOverflow
主题中进行了讨论:
One of the recommended uses of the ScheduledExecutorService is as a direct replacement for the Timer class, as discussed in numerous StackOverflow
topics already:
- Java Timer与ExecutorService?
- TimerTask与Executors.newScheduledThreadPool(1)之间的区别
- schedule和scheduleAtFixedRate有什么区别?
- Android计时器时间表与scheduleAtFixedRate
但是, ScheduledExecutorService
和 Timer
支持的方法的命名约定不同.例如,尽管它们都具有 scheduleAtFixedRate()
方法,但是Timer方法
However, the naming conventions of the methods supported by ScheduledExecutorService
and Timer
, are not identical. For example, whereas they both have a scheduleAtFixedRate()
method, the Timer method
- 时间表(TimerTask任务,延迟长,时间长)
没有同名对手.
是 ScheduledExecutorService
方法
- scheduleWithFixedDelay(可运行命令,长initialDelay,长延迟,TimeUnit单位)
要代替的那个?
推荐答案
查看全文