Package org.apache.camel.util.concurrent
Class RejectableThreadPoolExecutor
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- org.apache.camel.util.concurrent.RejectableThreadPoolExecutor
-
- All Implemented Interfaces:
Executor,ExecutorService
public class RejectableThreadPoolExecutor extends ThreadPoolExecutor
Thread pool executor that createsRejectableFutureTaskinstead ofFutureTaskwhen registering new tasks for execution. Instances ofRejectableFutureTaskare required to handleThreadPoolRejectedPolicy.DiscardandThreadPoolRejectedPolicy.DiscardOldestpolicies correctly, e.g. notifyCallableandRunnabletasks when they are rejected. To be notified of rejection tasks have to implementRejectableinterface:
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 } }Rejectableinterface the behavior is exactly the same as with ordinaryThreadPoolExecutor.
-
-
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 RejectableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)RejectableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)RejectableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)RejectableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, 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)StringtoString()-
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated
-
-
-
-
Constructor Detail
-
RejectableThreadPoolExecutor
public RejectableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
-
RejectableThreadPoolExecutor
public RejectableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
-
RejectableThreadPoolExecutor
public RejectableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)
-
RejectableThreadPoolExecutor
public RejectableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
-
Method Detail
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
- Overrides:
newTaskForin classAbstractExecutorService
-
newTaskFor
protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable)
- Overrides:
newTaskForin classAbstractExecutorService
-
toString
public String toString()
- Overrides:
toStringin classThreadPoolExecutor
-
-