public final class Scheduler extends Object
Modifier and Type | Method and Description |
---|---|
static void |
cancelAllTasks()
Cancels all running tasks/threads and clears the cached queue.
|
static ScheduledExecutorService |
getService()
Returns the underlying
ScheduledExecutorService used for this
utility class |
static ScheduledFuture<?> |
runAsyncTask(Runnable r)
Immediately runs a single asynchronous task
|
static ScheduledFuture<?> |
runAsyncTask(Runnable r,
long delay)
Runs a single asynchronous task
|
static ScheduledFuture<?> |
runAsyncTaskRepeat(Runnable r,
long startAfter,
long delay)
Runs a repeating asynchronous task
|
static <T> ScheduledFuture<T> |
runCallable(Callable<T> c,
long delay)
Runs a Callable
|
public static ScheduledFuture<?> runAsyncTaskRepeat(Runnable r, long startAfter, long delay)
r
- The runnable to executestartAfter
- Time (in seconds) to wait before executiondelay
- Time (in seconds) between execution to waitpublic static ScheduledFuture<?> runAsyncTask(Runnable r, long delay)
r
- The runnable to executedelay
- Time (in seconds) to wait before executionpublic static ScheduledFuture<?> runAsyncTask(Runnable r)
r
- The runnable to executepublic static <T> ScheduledFuture<T> runCallable(Callable<T> c, long delay)
T
- The return type of the Callable
c
- The callable to executedelay
- Time (in seconds) to wait before executionpublic static void cancelAllTasks()
public static ScheduledExecutorService getService()
ScheduledExecutorService
used for this
utility classScheduledExecutorService
Copyright © 2017. All rights reserved.