public interface SilentScheduledExecutorService extends ScheduledExecutorService
ScheduledExecutorService by providing additional methods to enqueue tasks without
throwing a RejectedExecutionException exception.Exceptions for control flow is an anti pattern).| Modifier and Type | Method and Description |
|---|---|
void |
silentExecute(Runnable command)
Does the same as
Executor.execute(Runnable) but doesn't throw a
RejectedExecutionException if this task cannot be accepted for execution. |
<T> List<Future<T>> |
silentInvokeAll(Collection<? extends Callable<T>> tasks)
Does the same as
ExecutorService.invokeAll(Collection) but returns null instead of
throwing a RejectedExecutionException if any task cannot be scheduled for execution. |
<T> List<Future<T>> |
silentInvokeAll(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit)
Does the same as
ExecutorService.invokeAll(Collection, long, TimeUnit) but returns null
instead of throwing a RejectedExecutionException if any task cannot be scheduled for execution. |
<T> T |
silentInvokeAny(Collection<? extends Callable<T>> tasks)
Does the same as
ExecutorService.invokeAny(Collection) but returns null instead of
throwing a RejectedExecutionException if tasks cannot be scheduled for execution. |
<T> T |
silentInvokeAny(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit)
Does the same as
ExecutorService.invokeAny(Collection, long, TimeUnit) but returns null
instead of throwing a RejectedExecutionException if tasks cannot be scheduled for execution. |
<V> ScheduledFuture<V> |
silentSchedule(Callable<V> callable,
long delay,
TimeUnit unit)
Does the same as
ScheduledExecutorService.schedule(Callable, long, TimeUnit) but returns null
instead of throwing a RejectedExecutionException if the task cannot be scheduled for
execution. |
ScheduledFuture<?> |
silentSchedule(Runnable command,
long delay,
TimeUnit unit)
Does the same as
ScheduledExecutorService.schedule(Runnable, long, TimeUnit) but returns null
instead of throwing a RejectedExecutionException if the task cannot be scheduled for execution. |
ScheduledFuture<?> |
silentScheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit)
Does the same as
ScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit) but returns
null instead of throwing a RejectedExecutionException if the task cannot be scheduled for
execution. |
ScheduledFuture<?> |
silentScheduleWithFixedDelay(Runnable command,
long initialDelay,
long delay,
TimeUnit unit)
Does the same as
ScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit) but returns null
instead of throwing a RejectedExecutionException if the task cannot be scheduled for execution. |
<T> Future<T> |
silentSubmit(Callable<T> task)
Does the same as
ExecutorService.submit(Callable) but returns null instead of throwing a
RejectedExecutionException if the task cannot be scheduled for execution. |
Future<?> |
silentSubmit(Runnable task)
Does the same as
ExecutorService.submit(Runnable) but returns null instead of throwing a
RejectedExecutionException if the task cannot be scheduled for execution. |
<T> Future<T> |
silentSubmit(Runnable task,
T result)
Does the same as
ExecutorService.submit(Runnable, Object) but returns null instead of
throwing a RejectedExecutionException if the task cannot be scheduled for execution. |
schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelayawaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submitScheduledFuture<?> silentSchedule(Runnable command, long delay, TimeUnit unit)
ScheduledExecutorService.schedule(Runnable, long, TimeUnit) but returns null
instead of throwing a RejectedExecutionException if the task cannot be scheduled for execution.command - the task to executedelay - the time from now to delay executionunit - the time unit of the delay parameterget() method will return
null upon completion / null if the task cannot be scheduled for executionNullPointerException - if command is null<V> ScheduledFuture<V> silentSchedule(Callable<V> callable, long delay, TimeUnit unit)
ScheduledExecutorService.schedule(Callable, long, TimeUnit) but returns null
instead of throwing a RejectedExecutionException if the task cannot be scheduled for
execution.V - the type of the callable's resultcallable - the function to executedelay - the time from now to delay executionunit - the time unit of the delay parameternull if the task cannot be
scheduled for executionNullPointerException - if callable is nullScheduledFuture<?> silentScheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
ScheduledExecutorService.scheduleAtFixedRate(Runnable, long, long, TimeUnit) but returns
null instead of throwing a RejectedExecutionException if the task cannot be scheduled for
execution.command - the task to executeinitialDelay - the time to delay first executionperiod - the period between successive executionsunit - the time unit of the initialDelay and period parametersget() method will throw
an exception upon cancellation / null if the task cannot be scheduled for executionNullPointerException - if command is nullIllegalArgumentException - if period less than or equal to zeroScheduledFuture<?> silentScheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
ScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit) but returns null
instead of throwing a RejectedExecutionException if the task cannot be scheduled for execution.command - the task to executeinitialDelay - the time to delay first executiondelay - the delay between the termination of one execution and the commencement of the nextunit - the time unit of the initialDelay and delay parametersget() method will throw
an exception upon cancellation / null if the task cannot be scheduled for executionNullPointerException - if command is nullIllegalArgumentException - if delay less than or equal to zero<T> Future<T> silentSubmit(Callable<T> task)
ExecutorService.submit(Callable) but returns null instead of throwing a
RejectedExecutionException if the task cannot be scheduled for execution.T - the type of the task's resulttask - the task to submitnull if the task cannot be scheduled for executionNullPointerException - if the task is nullFuture<?> silentSubmit(Runnable task)
ExecutorService.submit(Runnable) but returns null instead of throwing a
RejectedExecutionException if the task cannot be scheduled for execution.task - the task to submitnull if the task cannot be scheduled for
executionNullPointerException - if the task is null<T> Future<T> silentSubmit(Runnable task, T result)
ExecutorService.submit(Runnable, Object) but returns null instead of
throwing a RejectedExecutionException if the task cannot be scheduled for execution.T - the type of the resulttask - the task to submitresult - the result to returnnull if the task cannot be scheduled for
executionNullPointerException - if the task is null<T> List<Future<T>> silentInvokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
ExecutorService.invokeAll(Collection) but returns null instead of
throwing a RejectedExecutionException if any task cannot be scheduled for execution.T - the type of the values returned from the taskstasks - the collection of tasksnull if any task cannot be scheduled for
executionInterruptedException - if interrupted while waiting, in which case unfinished tasks are cancelledNullPointerException - if tasks or any of its elements are null<T> List<Future<T>> silentInvokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
ExecutorService.invokeAll(Collection, long, TimeUnit) but returns null
instead of throwing a RejectedExecutionException if any task cannot be scheduled for execution.T - the type of the values returned from the taskstasks - the collection of taskstimeout - the maximum time to waitunit - the time unit of the timeout argumentnull if any task cannot be scheduled
for execution.InterruptedException - if interrupted while waiting, in which case unfinished tasks are cancelledNullPointerException - if tasks, any of its elements, or unit are null<T> T silentInvokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
ExecutorService.invokeAny(Collection) but returns null instead of
throwing a RejectedExecutionException if tasks cannot be scheduled for execution.T - the type of the values returned from the taskstasks - the collection of tasksnull if tasks cannot be scheduled for executionInterruptedException - if interrupted while waitingNullPointerException - if tasks or any element task subject to execution is nullIllegalArgumentException - if tasks is emptyExecutionException - if no task successfully completes<T> T silentInvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
ExecutorService.invokeAny(Collection, long, TimeUnit) but returns null
instead of throwing a RejectedExecutionException if tasks cannot be scheduled for execution.T - the type of the values returned from the taskstasks - the collection of taskstimeout - the maximum time to waitunit - the time unit of the timeout argumentnull if tasks cannot be scheduled for executionInterruptedException - if interrupted while waitingNullPointerException - if tasks, or unit, or any element task subject to execution is nullTimeoutException - if the given timeout elapses before any task successfully completesExecutionException - if no task successfully completesvoid silentExecute(Runnable command)
Executor.execute(Runnable) but doesn't throw a
RejectedExecutionException if this task cannot be accepted for execution.command - the runnable taskNullPointerException - if command is nullCopyright © 2019. All rights reserved.