Package jmri.jmrit.logixng.util
Class ProtectedTimerTask
- java.lang.Object
-
- java.util.TimerTask
-
- jmri.jmrit.logixng.util.ProtectedTimerTask
-
- All Implemented Interfaces:
java.lang.Runnable
public abstract class ProtectedTimerTask extends java.util.TimerTask
A timer task that can be stopped, and there the stop method waits until the task is finished.Note that this class does [u]not[/u] work for repeating timers. The class can be used for tasks that are scheduled over and over again, but only works for one shoot timer.
In other words, the class works for TimerUtil.schedule(@Nonnull TimerTask task, long delay) but not for TimerUtil.schedule(@Nonnull TimerTask task, long delay, long period). This is due to how the method TimerTask.cancel() works.
-
-
Constructor Summary
Constructors Constructor Description ProtectedTimerTask()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
execute()
void
run()
void
stopTimer()
Stop the timer.
-
-
-
Constructor Detail
-
ProtectedTimerTask
public ProtectedTimerTask()
-
-
Method Detail
-
execute
public abstract void execute()
-
run
public final void run()
- Specified by:
run
in interfacejava.lang.Runnable
- Specified by:
run
in classjava.util.TimerTask
-
stopTimer
public void stopTimer()
Stop the timer. This method will not return until the timer task is cancelled and stopped. This code ensures that we don't return from this method until the timer task is cancelled and that it's not running any more.
-
-