public enum RejectPolicy extends Enum<RejectPolicy>
如果设置了maxSize, 当总线程数达到上限, 会调用RejectedExecutionHandler进行处理,此枚举为JDK预定义的几种策略枚举表示
Enum Constant and Description |
---|
ABORT
处理程序遭到拒绝将抛出RejectedExecutionException
|
BLOCK
当任务队列过长时处于阻塞状态,直到添加到队列中,固定并发数去访问,并且不希望丢弃任务时使用此策略
|
CALLER_RUNS
由主线程来直接执行
|
DISCARD
放弃当前任务
|
DISCARD_OLDEST
如果执行程序尚未关闭,则位于工作队列头部的任务将被删除,然后重试执行程序(如果再次失败,则重复此过程)
|
Modifier and Type | Method and Description |
---|---|
RejectedExecutionHandler |
getValue()
获取RejectedExecutionHandler枚举值
|
static RejectPolicy |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static RejectPolicy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final RejectPolicy ABORT
public static final RejectPolicy DISCARD
public static final RejectPolicy DISCARD_OLDEST
public static final RejectPolicy CALLER_RUNS
public static final RejectPolicy BLOCK
public static RejectPolicy[] values()
for (RejectPolicy c : RejectPolicy.values()) System.out.println(c);
public static RejectPolicy valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic RejectedExecutionHandler getValue()
Copyright © 2024. All rights reserved.