Interface Timer
-
- All Known Implementing Classes:
ThreadTimer
public interface TimerTimer allows scheduling tasks for execution in the future. Tasks are always executed on a well-definedExecutor. Timer implementations must have a default executor for tasks scheduled usingschedule(long, Runnable). Tasks scheduled usingschedule(long, Runnable, Executor)are executed on the given executor.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intcountScheduledTasks()Returns the number of tasks that are currently scheduled for execution by the timer.TimerTaskschedule(long delayInMillis, Runnable task)TimerTaskschedule(long delayInMillis, Runnable task, Executor executor)Schedules thetaskto be executed indelayInMillison givenexecutor.voidshutdown()Shuts down this timer.
-
-
-
Method Detail
-
schedule
TimerTask schedule(long delayInMillis, Runnable task)
Schedules thetaskto be executed indelayInMillison this timer's defaultExecutor.Equivalent to
schedule(delayInMillis, task, null).
-
schedule
TimerTask schedule(long delayInMillis, Runnable task, Executor executor)
Schedules thetaskto be executed indelayInMillison givenexecutor. Ifexecutorisnull, this timer's default executor is used.
-
countScheduledTasks
int countScheduledTasks()
Returns the number of tasks that are currently scheduled for execution by the timer. Finished tasks and tasks that are already running are not included.- Returns:
- the number of currently scheduled tasks
-
shutdown
void shutdown() throws InterruptedExceptionShuts down this timer. Returns after all internal resources of this timer are shut down.- Throws:
InterruptedException
-
-