public class MyThreadPoolExecutor extends ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| 构造器和说明 |
|---|
MyThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory,
RejectedExecutionHandler handler) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
execute(Runnable command) |
static ThreadPoolExecutor |
getSimplePool(String name)
构建简单线程池
|
<T> Future<T> |
submit(Callable<T> task) |
static <T> Callable<T> |
wrap(Callable<T> callable,
Map<String,String> context)
用于父线程向线程池中提交任务时,将自身MDC中的数据赋值给子线程
|
static Runnable |
wrap(Runnable runnable,
Map<String,String> context)
用于父线程向线程池中提交任务时,将自身MDC中的数据赋值给子线程
|
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, toStringinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submitpublic MyThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory,
RejectedExecutionHandler handler)
public static ThreadPoolExecutor getSimplePool(String name)
name - 名称public void execute(Runnable command)
execute 在接口中 Executorexecute 在类中 ThreadPoolExecutorpublic <T> Future<T> submit(Callable<T> task)
submit 在接口中 ExecutorServicesubmit 在类中 AbstractExecutorServicepublic static <T> Callable<T> wrap(Callable<T> callable, Map<String,String> context)
T - 类型callable - 线程任务context - MDC ContextCopyright © 2024. All rights reserved.