public final class ThreadPoolExecutors extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static RejectedExecutionHandler |
ABORT
abort and throw RejectedExecutionException
|
static RejectedExecutionHandler |
ALWAYS_CALLER_RUNS
anyway always run
|
static RejectedExecutionHandler |
CALLER_BLOCKS
if not shutdown then put queue until enqueue
|
static RejectedExecutionHandler |
CALLER_RUNS
if not shutdown then run
|
static RejectedExecutionHandler |
DISCARD
discard the task
|
static RejectedExecutionHandler |
DISCARD_OLDEST
if not shutdown then discard oldest and execute the new
|
static int |
MAX_CAP |
| 构造器和说明 |
|---|
ThreadPoolExecutors() |
| 限定符和类型 | 方法和说明 |
|---|---|
static ThreadPoolExecutor |
create(int corePoolSize,
int maximumPoolSize,
long keepAliveTimeSeconds) |
static ThreadPoolExecutor |
create(int corePoolSize,
int maximumPoolSize,
long keepAliveTimeSeconds,
int queueCapacity) |
static ThreadPoolExecutor |
create(int corePoolSize,
int maximumPoolSize,
long keepAliveTimeSeconds,
int queueCapacity,
RejectedExecutionHandler rejectedHandler) |
static ThreadPoolExecutor |
create(int corePoolSize,
int maximumPoolSize,
long keepAliveTimeSeconds,
int queueCapacity,
String threadName) |
static ThreadPoolExecutor |
create(int corePoolSize,
int maximumPoolSize,
long keepAliveTimeSeconds,
int queueCapacity,
String threadName,
RejectedExecutionHandler rejectedHandler)
Creates a new ThreadPoolExecutor
|
static boolean |
shutdown(ExecutorService executorService)
Shutdown the ExecutorService safe
|
static boolean |
shutdown(ExecutorService executorService,
int awaitSeconds)
Shutdown the executorService max wait time
|
public static final int MAX_CAP
public static final RejectedExecutionHandler ABORT
public static final RejectedExecutionHandler DISCARD
public static final RejectedExecutionHandler CALLER_RUNS
public static final RejectedExecutionHandler DISCARD_OLDEST
public static final RejectedExecutionHandler CALLER_BLOCKS
public static final RejectedExecutionHandler ALWAYS_CALLER_RUNS
public static ThreadPoolExecutor create(int corePoolSize, int maximumPoolSize, long keepAliveTimeSeconds)
public static ThreadPoolExecutor create(int corePoolSize, int maximumPoolSize, long keepAliveTimeSeconds, int queueCapacity)
public static ThreadPoolExecutor create(int corePoolSize, int maximumPoolSize, long keepAliveTimeSeconds, int queueCapacity, RejectedExecutionHandler rejectedHandler)
public static ThreadPoolExecutor create(int corePoolSize, int maximumPoolSize, long keepAliveTimeSeconds, int queueCapacity, String threadName)
public static ThreadPoolExecutor create(int corePoolSize, int maximumPoolSize, long keepAliveTimeSeconds, int queueCapacity, String threadName, RejectedExecutionHandler rejectedHandler)
corePoolSize - 核心线程数maximumPoolSize - 最大线程数keepAliveTimeSeconds - 线程存活时间(秒)queueCapacity - 队列长度threadName - 线程名称rejectedHandler - 拒绝策略public static boolean shutdown(ExecutorService executorService)
executorService - the executorServicepublic static boolean shutdown(ExecutorService executorService, int awaitSeconds)
executorService - the executorServiceawaitSeconds - await time secondstrue if safe terminateCopyright © 2023. All rights reserved.