Package jmri.util

Class TimerUtil


public final class TimerUtil
extends Object
Common utility methods for working with (@link java.util.Timer)

Each Timer uses a thread, which means that they're not throw-away timers: You either track when you can destroy them (and that destruction is not obvious), or they stick around consuming resources.

This class provides most of the functionality of a Timer. Some differences:

  • When migrating code that uses Timer.cancel() to end operation, you have to retain references to the individual TimerTask objects and cancel them instead.

For convenience, this also provides methods to ensure that the task is invoked on a specific JMRI thread.

Please note the comment in the Timer Javadoc about how ScheduledThreadPoolExecutor might provide a better underlying implementation.