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