Package jmri.util
Class TimerUtil
- java.lang.Object
-
- jmri.util.TimerUtil
-
@Immutable public final class TimerUtil extends java.lang.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 howScheduledThreadPoolExecutor
might provide a better underlying implementation.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.Timer
commonTimer
-
Constructor Summary
Constructors Constructor Description TimerUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
schedule(java.util.TimerTask task, long delay)
static void
schedule(java.util.TimerTask task, long delay, long period)
static void
schedule(java.util.TimerTask task, java.util.Date time)
static void
schedule(java.util.TimerTask task, java.util.Date firstTime, long period)
static void
scheduleAtFixedRate(java.util.TimerTask task, long delay, long period)
static void
scheduleAtFixedRate(java.util.TimerTask task, java.util.Date firstTime, long period)
static void
scheduleAtFixedRateOnGUIThread(java.util.TimerTask task, long delay, long period)
static void
scheduleAtFixedRateOnGUIThread(java.util.TimerTask task, java.util.Date firstTime, long period)
static void
scheduleAtFixedRateOnLayoutThread(java.util.TimerTask task, long delay, long period)
static void
scheduleAtFixedRateOnLayoutThread(java.util.TimerTask task, java.util.Date firstTime, long period)
static void
scheduleOnGUIThread(java.util.TimerTask task, long delay)
static void
scheduleOnGUIThread(java.util.TimerTask task, long delay, long period)
static void
scheduleOnGUIThread(java.util.TimerTask task, java.util.Date time)
static void
scheduleOnGUIThread(java.util.TimerTask task, java.util.Date firstTime, long period)
static void
scheduleOnLayoutThread(java.util.TimerTask task, long delay)
static void
scheduleOnLayoutThread(java.util.TimerTask task, long delay, long period)
static void
scheduleOnLayoutThread(java.util.TimerTask task, java.util.Date time)
static void
scheduleOnLayoutThread(java.util.TimerTask task, java.util.Date firstTime, long period)
-
-
-
Field Detail
-
commonTimer
static final java.util.Timer commonTimer
-
-
Constructor Detail
-
TimerUtil
public TimerUtil()
-
-
Method Detail
-
schedule
public static void schedule(@Nonnull java.util.TimerTask task, @Nonnull java.util.Date time)
-
schedule
public static void schedule(@Nonnull java.util.TimerTask task, @Nonnull java.util.Date firstTime, long period)
-
scheduleAtFixedRate
public static void scheduleAtFixedRate(@Nonnull java.util.TimerTask task, @Nonnull java.util.Date firstTime, long period)
-
scheduleAtFixedRate
public static void scheduleAtFixedRate(@Nonnull java.util.TimerTask task, long delay, long period)
-
scheduleOnGUIThread
public static void scheduleOnGUIThread(@Nonnull java.util.TimerTask task, @Nonnull java.util.Date time)
-
scheduleOnGUIThread
public static void scheduleOnGUIThread(@Nonnull java.util.TimerTask task, @Nonnull java.util.Date firstTime, long period)
-
scheduleOnGUIThread
public static void scheduleOnGUIThread(@Nonnull java.util.TimerTask task, long delay)
-
scheduleOnGUIThread
public static void scheduleOnGUIThread(@Nonnull java.util.TimerTask task, long delay, long period)
-
scheduleAtFixedRateOnGUIThread
public static void scheduleAtFixedRateOnGUIThread(@Nonnull java.util.TimerTask task, @Nonnull java.util.Date firstTime, long period)
-
scheduleAtFixedRateOnGUIThread
public static void scheduleAtFixedRateOnGUIThread(@Nonnull java.util.TimerTask task, long delay, long period)
-
scheduleOnLayoutThread
public static void scheduleOnLayoutThread(@Nonnull java.util.TimerTask task, @Nonnull java.util.Date time)
-
scheduleOnLayoutThread
public static void scheduleOnLayoutThread(@Nonnull java.util.TimerTask task, @Nonnull java.util.Date firstTime, long period)
-
scheduleOnLayoutThread
public static void scheduleOnLayoutThread(@Nonnull java.util.TimerTask task, long delay)
-
scheduleOnLayoutThread
public static void scheduleOnLayoutThread(@Nonnull java.util.TimerTask task, long delay, long period)
-
scheduleAtFixedRateOnLayoutThread
public static void scheduleAtFixedRateOnLayoutThread(@Nonnull java.util.TimerTask task, @Nonnull java.util.Date firstTime, long period)
-
scheduleAtFixedRateOnLayoutThread
public static void scheduleAtFixedRateOnLayoutThread(@Nonnull java.util.TimerTask task, long delay, long period)
-
-