RejectedExecutionHandler
Stay organized with collections
Save and categorize content based on your preferences.
Known Indirect Subclasses
|
Public Methods
public
abstract
void
rejectedExecution
(Runnable r, ThreadPoolExecutor executor)
Method that may be invoked by a ThreadPoolExecutor
when
execute
cannot accept a
task. This may occur when no more threads or queue slots are
available because their bounds would be exceeded, or upon
shutdown of the Executor.
In the absence of other alternatives, the method may throw
an unchecked RejectedExecutionException
, which will be
propagated to the caller of execute
.
Parameters
r |
the runnable task requested to be executed |
executor |
the executor attempting to execute this task |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eRejectedExecutionHandler\u003c/code\u003e is an interface used to handle tasks that a \u003ccode\u003eThreadPoolExecutor\u003c/code\u003e cannot execute.\u003c/p\u003e\n"],["\u003cp\u003eIt defines a single method, \u003ccode\u003erejectedExecution\u003c/code\u003e, which is invoked when a task is rejected.\u003c/p\u003e\n"],["\u003cp\u003eImplementations of this interface provide custom logic for handling rejected tasks, such as discarding, re-queuing, or throwing an exception.\u003c/p\u003e\n"],["\u003cp\u003eFour built-in implementations are available: \u003ccode\u003eAbortPolicy\u003c/code\u003e, \u003ccode\u003eCallerRunsPolicy\u003c/code\u003e, \u003ccode\u003eDiscardOldestPolicy\u003c/code\u003e, and \u003ccode\u003eDiscardPolicy\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003erejectedExecution\u003c/code\u003e is called when a \u003ccode\u003eThreadPoolExecutor\u003c/code\u003e is saturated or shut down, providing a mechanism to manage task overflow.\u003c/p\u003e\n"]]],[],null,[]]