| Constructor and Description |
|---|
DefaultScheduler()
Creates a scheduler with a ScheduledThreadPoolExecutor.
|
DefaultScheduler(int poolSize)
Creates a scheduler with a ScheduledThreadPoolExecutor.
|
DefaultScheduler(java.util.concurrent.ScheduledExecutorService scheduled)
Creates a scheduler instance with the given backing pool.
|
| Modifier and Type | Method and Description |
|---|---|
java.io.Closeable |
schedule(java.lang.Runnable run)
Schedule for ASAP execution.
|
java.io.Closeable |
schedule(java.lang.Runnable run,
long initialDelay,
long betweenDelay,
java.util.concurrent.TimeUnit unit)
Schedule a repeated execution of the given task with
the given initialDelay (in nanoseconds) and betweenDelay
(in nanoseconds).
|
java.io.Closeable |
schedule(java.lang.Runnable run,
long delay,
java.util.concurrent.TimeUnit unit)
Schedule a single execution of the runnable task
with the given delay of nanoseconds.
|
void |
shutdown()
Shutdown both pools.
|
java.util.List<java.lang.Runnable> |
shutdownNow()
Shutdown both pools now.
|
protected java.io.Closeable |
toCloseable(java.util.concurrent.Future<?> future)
Factory function to turn the future into a closeable instance.
|
public DefaultScheduler()
Runtime.getRuntime().availableProcessors() core threadpublic DefaultScheduler(int poolSize)
parallellism core threadpoolSize - the number of core threadspublic DefaultScheduler(@Nonnull
java.util.concurrent.ScheduledExecutorService scheduled)
scheduled - the backing scheduled executor service@Nonnull
public java.io.Closeable schedule(@Nonnull
java.lang.Runnable run)
Scheduler@Nonnull
public java.io.Closeable schedule(@Nonnull
java.lang.Runnable run,
long delay,
@Nonnull
java.util.concurrent.TimeUnit unit)
Scheduler@Nonnull
public java.io.Closeable schedule(@Nonnull
java.lang.Runnable run,
long initialDelay,
long betweenDelay,
@Nonnull
java.util.concurrent.TimeUnit unit)
SchedulerExecutorService.scheduleAtFixedRate()).
Note: Implementations might not have the capability to
schedule nanosecond resolution.@Nonnull
protected java.io.Closeable toCloseable(@Nonnull
java.util.concurrent.Future<?> future)
future - the future to work withpublic void shutdown()
public java.util.List<java.lang.Runnable> shutdownNow()