public class CronExecutorService extends Object implements ScheduledExecutorService
ScheduledExecutorService on top of a cached thread pool to achieve UNIX's cron-like capabilities.
This executor service is implemented with two underlying executor services:
a single-thread scheduled executor which
allows to start tasks based on a schedulea cached thread pool which allows to run several
tasks concurrently, adjusting the thread pool size when necessary. In particular, when the number
of tasks to run concurrently is bigger than the tread pool size, then new threads are spawned.
The thread pool is then shrinked when threads sit idle with no tasks to execute.All the tasks submitted to the current class are 1. scheduled by the single-thread scheduled executor and 2. finally executed by the cached thread pool.
Because of this setup, the assumptions of
scheduleWithFixedDelay(Runnable, long, long, TimeUnit) cannot be fulfilled, so calling
this method will throw a UnsupportedOperationException.
Current (Nov. 2016) OpenDJ threads that may be replaced by using the current class:
| Constructor and Description |
|---|
CronExecutorService()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
void |
execute(Runnable task) |
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks) |
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks) |
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
boolean |
isShutdown() |
boolean |
isTerminated() |
<V> ScheduledFuture<V> |
schedule(Callable<V> task,
long delay,
TimeUnit unit) |
ScheduledFuture<?> |
schedule(Runnable task,
long delay,
TimeUnit unit) |
ScheduledFuture<?> |
scheduleAtFixedRate(Runnable task,
long initialDelay,
long period,
TimeUnit unit) |
ScheduledFuture<?> |
scheduleWithFixedDelay(Runnable task,
long initialDelay,
long delay,
TimeUnit unit) |
void |
shutdown() |
List<Runnable> |
shutdownNow() |
<T> Future<T> |
submit(Callable<T> task) |
Future<?> |
submit(Runnable task) |
<T> Future<T> |
submit(Runnable task,
T result) |
public Future<?> submit(Runnable task)
submit in interface ExecutorServicepublic <T> Future<T> submit(Runnable task, T result)
submit in interface ExecutorServicepublic <T> Future<T> submit(Callable<T> task)
submit in interface ExecutorServicepublic ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
scheduleAtFixedRate in interface ScheduledExecutorServicepublic ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit)
scheduleWithFixedDelay in interface ScheduledExecutorServicepublic <V> ScheduledFuture<V> schedule(Callable<V> task, long delay, TimeUnit unit)
schedule in interface ScheduledExecutorServicepublic ScheduledFuture<?> schedule(Runnable task, long delay, TimeUnit unit)
schedule in interface ScheduledExecutorServicepublic <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
invokeAny in interface ExecutorServiceInterruptedExceptionExecutionExceptionTimeoutExceptionpublic <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
invokeAny in interface ExecutorServiceInterruptedExceptionExecutionExceptionpublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedExceptionpublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedExceptionpublic boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface ExecutorServiceInterruptedExceptionpublic void shutdown()
shutdown in interface ExecutorServicepublic List<Runnable> shutdownNow()
shutdownNow in interface ExecutorServicepublic boolean isShutdown()
isShutdown in interface ExecutorServicepublic boolean isTerminated()
isTerminated in interface ExecutorServiceCopyright © 2010-2020 Wren Security. All Rights Reserved.