Class ThreadTimer
java.lang.Object
io.smallrye.faulttolerance.core.timer.ThreadTimer
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionThreadTimer(Executor defaultExecutor) Creates a timer with givendefaultExecutor, unless a timer already exists, in which case an exception is thrown. -
Method Summary
-
Constructor Details
-
ThreadTimer
Creates a timer with givendefaultExecutor, unless a timer already exists, in which case an exception is thrown.- Parameters:
defaultExecutor- defaultExecutorused for running scheduled tasks, unless an executor is provided when scheduling a task
-
-
Method Details
-
getId
public int getId()Description copied from interface:TimerReturns the ID of this timer. Timer IDs are guaranteed to be unique. -
schedule
Description copied from interface:TimerSchedules thetaskto be executed indelayInMillison this timer's defaultExecutor.Equivalent to
schedule(delayInMillis, task, null). -
schedule
Description copied from interface:TimerSchedules thetaskto be executed indelayInMillison givenexecutor. Ifexecutorisnull, this timer's default executor is used. -
countScheduledTasks
public int countScheduledTasks()Description copied from interface:TimerReturns the number of tasks that are currently scheduled for execution by the timer. Finished tasks and tasks that are already running are not included.- Specified by:
countScheduledTasksin interfaceTimer- Returns:
- the number of currently scheduled tasks
-
shutdown
Description copied from interface:TimerShuts down this timer. Returns after all internal resources of this timer are shut down.- Specified by:
shutdownin interfaceTimer- Throws:
InterruptedException
-