- 所有已知的实现类:
ThreadPoolExecutor.AbortPolicy,ThreadPoolExecutor.CallerRunsPolicy,ThreadPoolExecutor.DiscardOldestPolicy,ThreadPoolExecutor.DiscardPolicy
public interface RejectedExecutionHandler
ThreadPoolExecutor 无法执行的任务的处理程序。
- 自从:
- 1.5
-
方法总结
修饰符和类型方法描述voidrejectedExecution(Runnable r, ThreadPoolExecutor executor) 当execute无法接受任务时,ThreadPoolExecutor可能调用的方法。
-
方法详情
-
rejectedExecution
当execute无法接受任务时,ThreadPoolExecutor可能调用的方法。当没有更多的线程或队列槽可用时,可能会发生这种情况,因为它们的边界将被超出,或者在执行器关闭时。在没有其他选择的情况下,该方法可能会抛出一个未经检查的
RejectedExecutionException,它将传播到execute的调用者。- 参数:
r- 请求执行的可运行任务executor- 试图执行此任务的执行者- 抛出:
RejectedExecutionException- 如果没有补救措施
-