Package gov.nasa.worldwind.util
Interface ScheduledTaskService
-
- All Known Implementing Classes:
BasicScheduledTaskService
public interface ScheduledTaskServiceA service to execute tasks periodically, or after a delay.- See Also:
TaskService
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.ScheduledFuture<?>addRepeatingTask(java.lang.Runnable runnable, long initialDelay, long period, java.util.concurrent.TimeUnit timeUnit)Enqueues a task to run periodically.java.util.concurrent.ScheduledFuture<?>addScheduledTask(java.lang.Runnable runnable, long delay, java.util.concurrent.TimeUnit timeUnit)Enqueues a task to run after a delay.voidaddTask(java.lang.Runnable runnable)Enqueues a task to run.voidshutdown(boolean immediately)Shut down the service.
-
-
-
Method Detail
-
shutdown
void shutdown(boolean immediately)
Shut down the service. If theimmediateparameter istrue, the service will attempt to stop all active tasks, and will not begin work on any other tasks in the queue. Otherwise, the service will complete all tasks in the work queue, but will not accept any new tasks.- Parameters:
immediately-trueto shutdown immediately.
-
addTask
void addTask(java.lang.Runnable runnable)
Enqueues a task to run. Duplicate tasks are ignored.- Parameters:
runnable- the task to add- Throws:
java.lang.IllegalArgumentException- ifrunnableis null
-
addScheduledTask
java.util.concurrent.ScheduledFuture<?> addScheduledTask(java.lang.Runnable runnable, long delay, java.util.concurrent.TimeUnit timeUnit)Enqueues a task to run after a delay. Duplicate tasks are ignored.- Parameters:
runnable- the task to add.delay- delay before execution of the task.timeUnitdetermines the units of the value.timeUnit- time unit ofinitialDelayandperiod.- Returns:
- a ScheduledFuture that can be used to get the result of the task, or cancel the task, or
nullif the task was not enqueued. - Throws:
java.lang.IllegalArgumentException- ifrunnableis null
-
addRepeatingTask
java.util.concurrent.ScheduledFuture<?> addRepeatingTask(java.lang.Runnable runnable, long initialDelay, long period, java.util.concurrent.TimeUnit timeUnit)Enqueues a task to run periodically. This method follows the same semantics asScheduledExecutorService.scheduleAtFixedRate(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit). Duplicate tasks are ignored.- Parameters:
runnable- the task to add.initialDelay- delay before the first execution of the task.timeUnitdetermines the units of the value.period- interval between executions of the task.timeUnitdetermines the units of the value.timeUnit- time unit ofinitialDelayandperiod.- Returns:
- a ScheduledFuture that can be used to get the result of the task, or cancel the task, or
nullif the task was not enqueued. - Throws:
java.lang.IllegalArgumentException- ifrunnableis null
-
-