Class Timer
- java.lang.Object
-
- io.smallrye.faulttolerance.core.timer.Timer
-
public final class Timer extends Object
Allows scheduling tasks (Runnables) to be executed on anExecutorafter some delay.Starts one thread that processes submitted tasks in a loop and when it's time for a task to run, it gets submitted to the executor.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TimerTaskschedule(long delayInMillis, Runnable task)Schedules thetaskto be executed indelayInMillison theExecutorspecified when creating thisTimer.TimerTaskschedule(long delayInMillis, Runnable task, Executor executor)Schedules thetaskto be executed indelayInMillison givenexecutor.voidshutdown()Should be called before the underlyingexecutoris shut down.
-
-
-
Constructor Detail
-
Timer
public Timer(Executor executor)
- Parameters:
executor- defaultExecutorused for running scheduled tasks, unless an executor is provided whenschedulinga task
-
-
Method Detail
-
schedule
public TimerTask schedule(long delayInMillis, Runnable task)
Schedules thetaskto be executed indelayInMillison theExecutorspecified when creating thisTimer.Equivalent to
schedule(delayInMillis, task, null).
-
schedule
public TimerTask schedule(long delayInMillis, Runnable task, Executor executor)
Schedules thetaskto be executed indelayInMillison givenexecutor. Ifexecutorisnull, theExecutorspecified when creating thisTimeris used.
-
shutdown
public void shutdown() throws InterruptedExceptionShould be called before the underlyingexecutoris shut down. Returns only after the timer thread finishes.- Throws:
InterruptedException
-
-