Package org.miaixz.bus.core.lang.thread
Enum Class RejectPolicy
- All Implemented Interfaces:
Serializable,Comparable<RejectPolicy>,Constable
线程拒绝策略枚举
如果设置了maxSize, 当总线程数达到上限, 会调用RejectedExecutionHandler进行处理,此枚举为JDK预定义的几种策略枚举表示
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescription处理程序遭到拒绝将抛出RejectedExecutionException当任务队列过长时处于阻塞状态,直到添加到队列中,固定并发数去访问,并且不希望丢弃任务时使用此策略调用者线程来执行被丢弃的任务;一般可能是由主线程来直接执行放弃当前任务如果执行程序尚未关闭,则位于工作队列头部的任务将被删除,然后重试执行程序(如果再次失败,则重复此过程) -
Method Summary
Modifier and TypeMethodDescriptiongetValue()获取RejectedExecutionHandler枚举值static RejectPolicyReturns the enum constant of this class with the specified name.static RejectPolicy[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ABORT
处理程序遭到拒绝将抛出RejectedExecutionException -
DISCARD
放弃当前任务 -
DISCARD_OLDEST
如果执行程序尚未关闭,则位于工作队列头部的任务将被删除,然后重试执行程序(如果再次失败,则重复此过程) -
CALLER_RUNS
调用者线程来执行被丢弃的任务;一般可能是由主线程来直接执行 -
BLOCK
当任务队列过长时处于阻塞状态,直到添加到队列中,固定并发数去访问,并且不希望丢弃任务时使用此策略
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getValue
获取RejectedExecutionHandler枚举值- Returns:
- RejectedExecutionHandler
-