Executor, ExecutorServicepublic class MdcThreadPoolExecutor extends ForkJoinPool
ForkJoinPool.
In general, MDC is used to store diagnostic information (e.g. a user's session id) in per-thread variables, to facilitate
logging. However, although MDC data is passed to thread children, this doesn't work when threads are reused in a
thread pool. This is a drop-in replacement for ForkJoinPool sets MDC data before each task appropriately.
ForkJoinPool.ForkJoinWorkerThreadFactory, ForkJoinPool.ManagedBlockerdefaultForkJoinWorkerThreadFactory| Modifier and Type | Method | Description |
|---|---|---|
void |
execute(Runnable command) |
|
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks) |
|
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
|
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks) |
|
<T> T |
invokeAny(Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit) |
|
static MdcThreadPoolExecutor |
newWithCurrentMdc(int parallelism) |
Pool where task threads take fixed MDC from the thread that creates the pool.
|
static MdcThreadPoolExecutor |
newWithFixedMdc(Map<String,String> fixedContext,
int parallelism) |
Pool where task threads always have a specified, fixed MDC.
|
static MdcThreadPoolExecutor |
newWithInheritedMdc(int parallelism) |
Pool where task threads take MDC from the submitting thread.
|
ForkJoinTask<?> |
submit(Runnable task) |
|
<T> ForkJoinTask<T> |
submit(Runnable task,
T result) |
|
<T> ForkJoinTask<T> |
submit(Callable<T> task) |
awaitQuiescence, awaitTermination, commonPool, drainTasksTo, execute, getActiveThreadCount, getAsyncMode, getCommonPoolParallelism, getFactory, getParallelism, getPoolSize, getQueuedSubmissionCount, getQueuedTaskCount, getRunningThreadCount, getStealCount, getUncaughtExceptionHandler, hasQueuedSubmissions, invoke, isQuiescent, isShutdown, isTerminated, isTerminating, managedBlock, newTaskFor, newTaskFor, pollSubmission, shutdown, shutdownNow, submit, toStringpublic static MdcThreadPoolExecutor newWithInheritedMdc(int parallelism)
public static MdcThreadPoolExecutor newWithCurrentMdc(int parallelism)
public static MdcThreadPoolExecutor newWithFixedMdc(Map<String,String> fixedContext, int parallelism)
public void execute(Runnable command)
execute in interface Executorexecute in class ForkJoinPool@NotNull public <T> ForkJoinTask<T> submit(Callable<T> task)
submit in interface ExecutorServicesubmit in class ForkJoinPool@NotNull public <T> ForkJoinTask<T> submit(Runnable task, T result)
submit in interface ExecutorServicesubmit in class ForkJoinPool@NotNull public ForkJoinTask<?> submit(Runnable task)
submit in interface ExecutorServicesubmit in class ForkJoinPool@NotNull public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
invokeAll in interface ExecutorServiceinvokeAll in class ForkJoinPool@NotNull public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
invokeAll in interface ExecutorServiceinvokeAll in class AbstractExecutorServiceInterruptedException@NotNull public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
invokeAny in interface ExecutorServiceinvokeAny in class AbstractExecutorServicepublic <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
invokeAny in interface ExecutorServiceinvokeAny in class AbstractExecutorServiceCopyright © 2018. All rights reserved.