Class MDCThreadPoolExecutor

All Implemented Interfaces:
Executor, ExecutorService

public class MDCThreadPoolExecutor extends ThreadPoolExecutor
A variant of ThreadPoolExecutor which adds two behaviours:
  • The MDC diagnostic context map of the thread that executes the execute(Runnable) method is propagated to the runnable task.
  • If the runnable task throws an exception, it is wrapped in an MDCCapturingRuntimeException to preserve a copy of the MDC diagnostic context at the moment the exception occurred.