Package org.apache.camel.util.concurrent
Class RejectableScheduledThreadPoolExecutor
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- java.util.concurrent.ScheduledThreadPoolExecutor
-
- org.apache.camel.util.concurrent.RejectableScheduledThreadPoolExecutor
-
- All Implemented Interfaces:
Executor
,ExecutorService
,ScheduledExecutorService
public class RejectableScheduledThreadPoolExecutor extends ScheduledThreadPoolExecutor
Scheduled thread pool executor that createsRejectableFutureTask
instead ofFutureTask
when registering new tasks for execution. Instances ofRejectableFutureTask
are required to handleThreadPoolRejectedPolicy.Discard
andThreadPoolRejectedPolicy.DiscardOldest
policies correctly, e.g. notifyCallable
andRunnable
tasks when they are rejected. To be notified of rejection tasks have to implementRejectable
interface:
If the task does not implementpublic class RejectableTask implements Runnable, Rejectable { @Override public void run() { // execute task } @Override public void reject() { // do something useful on rejection } }
Rejectable
interface the behavior is exactly the same as with ordinaryScheduledThreadPoolExecutor
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
-
Constructor Summary
Constructors Constructor Description RejectableScheduledThreadPoolExecutor(int corePoolSize)
RejectableScheduledThreadPoolExecutor(int corePoolSize, RejectedExecutionHandler handler)
RejectableScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory)
RejectableScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T> RunnableFuture<T>
newTaskFor(Runnable runnable, T value)
protected <T> RunnableFuture<T>
newTaskFor(Callable<T> callable)
String
toString()
-
Methods inherited from class java.util.concurrent.ScheduledThreadPoolExecutor
decorateTask, decorateTask, execute, getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, getRemoveOnCancelPolicy, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, setContinueExistingPeriodicTasksAfterShutdownPolicy, setExecuteExistingDelayedTasksAfterShutdownPolicy, setRemoveOnCancelPolicy, shutdown, shutdownNow, submit, submit, submit
-
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
afterExecute, 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, terminated
-
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated
-
-
-
-
Constructor Detail
-
RejectableScheduledThreadPoolExecutor
public RejectableScheduledThreadPoolExecutor(int corePoolSize)
-
RejectableScheduledThreadPoolExecutor
public RejectableScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory)
-
RejectableScheduledThreadPoolExecutor
public RejectableScheduledThreadPoolExecutor(int corePoolSize, RejectedExecutionHandler handler)
-
RejectableScheduledThreadPoolExecutor
public RejectableScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
-
Method Detail
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
- Overrides:
newTaskFor
in classAbstractExecutorService
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable)
- Overrides:
newTaskFor
in classAbstractExecutorService
-
toString
public String toString()
- Overrides:
toString
in classThreadPoolExecutor
-
-