# RejectedExecutionHandler

public interface **RejectedExecutionHandler**

|---|---|---|
| Known Indirect Subclasses [ThreadPoolExecutor.AbortPolicy](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.AbortPolicy.html), [ThreadPoolExecutor.CallerRunsPolicy](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.CallerRunsPolicy.html), [ThreadPoolExecutor.DiscardOldestPolicy](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.DiscardOldestPolicy.html), [ThreadPoolExecutor.DiscardPolicy](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.DiscardPolicy.html) |---|---| | [ThreadPoolExecutor.AbortPolicy](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.AbortPolicy.html) | A handler for rejected tasks that throws a `RejectedExecutionException`. | | [ThreadPoolExecutor.CallerRunsPolicy](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.CallerRunsPolicy.html) | A handler for rejected tasks that runs the rejected task directly in the calling thread of the `execute` method, unless the executor has been shut down, in which case the task is discarded. | | [ThreadPoolExecutor.DiscardOldestPolicy](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.DiscardOldestPolicy.html) | A handler for rejected tasks that discards the oldest unhandled request and then retries `execute`, unless the executor is shut down, in which case the task is discarded. | | [ThreadPoolExecutor.DiscardPolicy](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.DiscardPolicy.html) | A handler for rejected tasks that silently discards the rejected task. | |||

A handler for tasks that cannot be executed by a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.html`.

### Public Method Summary

|---|---|
| abstract void | [rejectedExecution](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RejectedExecutionHandler.html#rejectedExecution(java.lang.Runnable,%20java.util.concurrent.ThreadPoolExecutor))([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) r, [ThreadPoolExecutor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.html) executor) Method that may be invoked by a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.html` when `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.html#execute(java.lang.Runnable)` cannot accept a task. |

## Public Methods

#### public abstract void
**rejectedExecution**
([Runnable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Runnable.html) r, [ThreadPoolExecutor](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.html) executor)

Method that may be invoked by a `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.html` when
`https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/ThreadPoolExecutor.html#execute(java.lang.Runnable)` 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 `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RejectedExecutionException.html`, 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 |
|---|---|

##### Throws

| [RejectedExecutionException](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/concurrent/RejectedExecutionException.html) | if there is no remedy |
|---|---|