模块 java.base

接口 RejectedExecutionHandler

所有已知的实现类:
ThreadPoolExecutor.AbortPolicy , ThreadPoolExecutor.CallerRunsPolicy , ThreadPoolExecutor.DiscardOldestPolicy , ThreadPoolExecutor.DiscardPolicy

public interface RejectedExecutionHandler
ThreadPoolExecutor 无法执行的任务的处理程序。
自从:
1.5
  • 方法详情

    • rejectedExecution

      void rejectedExecution(Runnable  r, ThreadPoolExecutor  executor)
      execute 无法接受任务时,ThreadPoolExecutor 可能调用的方法。当没有更多的线程或队列槽可用时,可能会发生这种情况,因为它们的边界将被超出,或者在执行器关闭时。

      在没有其他选择的情况下,该方法可能会抛出一个未经检查的 RejectedExecutionException ,它将传播到 execute 的调用者。

      参数:
      r - 请求执行的可运行任务
      executor - 试图执行此任务的执行者
      抛出:
      RejectedExecutionException - 如果没有补救措施