/* * [RejectedLinkProbeHandler.java] * * Summary: Handles probes rejected by the ThreadPoolExecutor. * * Copyright: (c) 2012-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2012-02-26 initial version */ package com.mindprod.brokenlinks; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; import static java.lang.System.*; /** * Handles probes rejected by the ThreadPoolExecutor. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2012-02-26 initial version * @since 2012-02-26 */ class RejectedLinkProbeHandler implements RejectedExecutionHandler { /** * Method that may be invoked by a {@link java.util.concurrent.ThreadPoolExecutor} when * {@link java.util.concurrent.ThreadPoolExecutor#execute 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 {@link java.util.concurrent.RejectedExecutionException}, which will be * propagated to the caller of {@code execute}. * * @param r the runnable task requested to be executed * @param executor the executor attempting to execute this task * * @throws java.util.concurrent.RejectedExecutionException if there is no remedy */ public void rejectedExecution( Runnable r, ThreadPoolExecutor executor ) { LinkProbe sp = ( LinkProbe ) r; err.println( "Warning: Link Probe rejected: " + sp.url ); executor.remove( r ); } }