| RejectedExecutionHandler.java |
1 /*
2 * %W% %E%
3 *
4 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
5 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6 */
7
8 package java.util.concurrent;
9
10 /**
11 * A handler for tasks that cannot be executed by a {@link ThreadPoolExecutor}.
12 *
13 * @since 1.5
14 * @author Doug Lea
15 */
16 public interface RejectedExecutionHandler {
17
18 /**
19 * Method that may be invoked by a {@link ThreadPoolExecutor} when
20 * {@link ThreadPoolExecutor#execute execute} cannot accept a
21 * task. This may occur when no more threads or queue slots are
22 * available because their bounds would be exceeded, or upon
23 * shutdown of the Executor.
24 *
25 * <p>In the absence of other alternatives, the method may throw
26 * an unchecked {@link RejectedExecutionException}, which will be
27 * propagated to the caller of {@code execute}.
28 *
29 * @param r the runnable task requested to be executed
30 * @param executor the executor attempting to execute this task
31 * @throws RejectedExecutionException if there is no remedy
32 */
33 void rejectedExecution(Runnable r, ThreadPoolExecutor executor);
34 }
35