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 vs ExecutorService?
- Difference between TimerTask and Executors.newScheduledThreadPool(1)
- What is the difference between schedule and scheduleAtFixedRate?
- Android Timer schedule vs scheduleAtFixedRate
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
- schedule(TimerTask task, long delay, long period)
does not have a namesake counterpart.
Is the ScheduledExecutorService
method
- scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
the one to use instead?