Package org.pepsoft.util.mdc
Class MDCThreadPoolExecutor
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
org.pepsoft.util.mdc.MDCThreadPoolExecutor
- All Implemented Interfaces:
Executor,ExecutorService
A variant of
ThreadPoolExecutor which adds two behaviours:
- The
MDCdiagnostic context map of the thread that executes theexecute(Runnable)method is propagated to the runnable task. - If the runnable task throws an exception, it is wrapped in an
MDCCapturingRuntimeExceptionto preserve a copy of theMDCdiagnostic context at the moment the exception occurred.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy -
Constructor Summary
ConstructorsConstructorDescriptionMDCThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) MDCThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidstatic ExecutorServicenewFixedThreadPool(int nThreads) static ExecutorServicenewFixedThreadPool(int nThreads, ThreadFactory threadFactory) Methods inherited from class java.util.concurrent.ThreadPoolExecutor
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, 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, toStringMethods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
Constructor Details
-
MDCThreadPoolExecutor
public MDCThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) -
MDCThreadPoolExecutor
public MDCThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
-
-
Method Details
-
execute
- Specified by:
executein interfaceExecutor- Overrides:
executein classThreadPoolExecutor
-
newFixedThreadPool
-
newFixedThreadPool
-