Enum Class RejectPolicy

java.lang.Object
java.lang.Enum<RejectPolicy>
org.miaixz.bus.core.lang.thread.RejectPolicy
All Implemented Interfaces:
Serializable, Comparable<RejectPolicy>, Constable

public enum RejectPolicy extends Enum<RejectPolicy>
线程拒绝策略枚举 如果设置了maxSize, 当总线程数达到上限, 会调用RejectedExecutionHandler进行处理,此枚举为JDK预定义的几种策略枚举表示
Since:
Java 17+
Author:
Kimi Liu
  • Enum Constant Details

    • ABORT

      public static final RejectPolicy ABORT
      处理程序遭到拒绝将抛出RejectedExecutionException
    • DISCARD

      public static final RejectPolicy DISCARD
      放弃当前任务
    • DISCARD_OLDEST

      public static final RejectPolicy DISCARD_OLDEST
      如果执行程序尚未关闭,则位于工作队列头部的任务将被删除,然后重试执行程序(如果再次失败,则重复此过程)
    • CALLER_RUNS

      public static final RejectPolicy CALLER_RUNS
      调用者线程来执行被丢弃的任务;一般可能是由主线程来直接执行
    • BLOCK

      public static final RejectPolicy BLOCK
      当任务队列过长时处于阻塞状态,直到添加到队列中,固定并发数去访问,并且不希望丢弃任务时使用此策略
  • Method Details

    • values

      public static RejectPolicy[] 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

      public static RejectPolicy valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • getValue

      public RejectedExecutionHandler getValue()
      获取RejectedExecutionHandler枚举值
      Returns:
      RejectedExecutionHandler