public class RejectableScheduledThreadPoolExecutor extends ScheduledThreadPoolExecutor
RejectableFutureTask instead of
FutureTask when registering new tasks for execution.
Instances of RejectableFutureTask are required to handle ThreadPoolRejectedPolicy.Discard and
ThreadPoolRejectedPolicy.DiscardOldest policies correctly, e.g. notify Callable and Runnable
tasks when they are rejected. To be notified of rejection tasks have to implement Rejectable interface:
public class RejectableTask implements Runnable, Rejectable {
@Override
public void run() {
// execute task
}
@Override
public void reject() {
// do something useful on rejection
}
}
If the task does not implement Rejectable interface the behavior is exactly the same as with ordinary
ScheduledThreadPoolExecutor.ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| Constructor and Description |
|---|
RejectableScheduledThreadPoolExecutor(int corePoolSize) |
RejectableScheduledThreadPoolExecutor(int corePoolSize,
RejectedExecutionHandler handler) |
RejectableScheduledThreadPoolExecutor(int corePoolSize,
ThreadFactory threadFactory) |
RejectableScheduledThreadPoolExecutor(int corePoolSize,
ThreadFactory threadFactory,
RejectedExecutionHandler handler) |
| Modifier and Type | Method and Description |
|---|---|
protected <T> RunnableFuture<T> |
newTaskFor(Callable<T> callable) |
protected <T> RunnableFuture<T> |
newTaskFor(Runnable runnable,
T value) |
String |
toString() |
decorateTask, decorateTask, execute, getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, getRemoveOnCancelPolicy, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, setContinueExistingPeriodicTasksAfterShutdownPolicy, setExecuteExistingDelayedTasksAfterShutdownPolicy, setRemoveOnCancelPolicy, shutdown, shutdownNow, submit, submit, submitafterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, terminatedinvokeAll, invokeAll, invokeAny, invokeAnyclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitawaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminatedpublic RejectableScheduledThreadPoolExecutor(int corePoolSize)
public RejectableScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory)
public RejectableScheduledThreadPoolExecutor(int corePoolSize, RejectedExecutionHandler handler)
public RejectableScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory, RejectedExecutionHandler handler)
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
newTaskFor in class AbstractExecutorServiceprotected <T> RunnableFuture<T> newTaskFor(Callable<T> callable)
newTaskFor in class AbstractExecutorServicepublic String toString()
toString in class ThreadPoolExecutorApache Camel