Class DefaultRejectedExecutionHandler
- java.lang.Object
-
- com.github.javinator9889.threading.pools.rejectedhandlers.DefaultRejectedExecutionHandler
-
- All Implemented Interfaces:
java.util.concurrent.RejectedExecutionHandler
public class DefaultRejectedExecutionHandler extends java.lang.Object implements java.util.concurrent.RejectedExecutionHandler
Default rejected execution handler that always throwsNoRejectedHandlerError
, with a message containing useful information:- Queue size for explaining why it has been rejected.
-
Executor information, a describer of
ThreadPoolExecutor
which calls the String method of that class. -
Thread information, a describer of
Runnable
which calls the String method of that class.
Defined at
ThreadsPooling.DEFAULT_REJECTED_EXECUTION_HANDLER
.
-
-
Constructor Summary
Constructors Constructor Description DefaultRejectedExecutionHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
rejectedExecution(java.lang.Runnable thread, java.util.concurrent.ThreadPoolExecutor executor)
Method that may be invoked by aThreadPoolExecutor
whenexecute
cannot accept a task.
-
-
-
Method Detail
-
rejectedExecution
public void rejectedExecution(java.lang.Runnable thread, java.util.concurrent.ThreadPoolExecutor executor)
Method that may be invoked by aThreadPoolExecutor
whenexecute
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 ofexecute
.- Specified by:
rejectedExecution
in interfacejava.util.concurrent.RejectedExecutionHandler
- Parameters:
thread
- the runnable task requested to be executedexecutor
- the executor attempting to execute this task- Throws:
java.util.concurrent.RejectedExecutionException
- alwaysNoRejectedHandlerError
- always - custom exception that is being thrown which inherits fromRejectedExecutionException
.- See Also:
NoRejectedHandlerError
-
-