Class ThreadTimer
- java.lang.Object
-
- io.smallrye.faulttolerance.core.timer.ThreadTimer
-
- All Implemented Interfaces:
Timer
public final class ThreadTimer extends Object implements Timer
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. The default executor is provided by a caller, so the caller must shut down this timer before shutting down the executor.
-
-
Constructor Summary
Constructors Constructor Description ThreadTimer(Executor defaultExecutor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TimerTaskschedule(long delayInMillis, Runnable task)TimerTaskschedule(long delayInMillis, Runnable task, Executor executor)Schedules thetaskto be executed indelayInMillison givenexecutor.voidshutdown()Shuts down this timer.
-
-
-
Constructor Detail
-
ThreadTimer
public ThreadTimer(Executor defaultExecutor)
- Parameters:
defaultExecutor- defaultExecutorused for running scheduled tasks, unless an executor is provided when scheduling a task
-
-
Method Detail
-
schedule
public TimerTask schedule(long delayInMillis, Runnable task)
Description copied from interface:TimerSchedules thetaskto be executed indelayInMillison this timer's defaultExecutor.Equivalent to
schedule(delayInMillis, task, null).
-
schedule
public TimerTask schedule(long delayInMillis, Runnable task, Executor executor)
Description copied from interface:TimerSchedules thetaskto be executed indelayInMillison givenexecutor. Ifexecutorisnull, this timer's default executor is used.
-
shutdown
public void shutdown() throws InterruptedExceptionDescription copied from interface:TimerShuts down this timer. Returns after all internal resources of this timer are shut down.- Specified by:
shutdownin interfaceTimer- Throws:
InterruptedException
-
-