Class ImmediatelyRunOnRejectedExecutionHandler
- java.lang.Object
-
- com.github.javinator9889.threading.pools.rejectedhandlers.ImmediatelyRunOnRejectedExecutionHandler
-
- All Implemented Interfaces:
java.util.concurrent.RejectedExecutionHandler
public class ImmediatelyRunOnRejectedExecutionHandler extends java.lang.Object implements java.util.concurrent.RejectedExecutionHandler
Rejected execution handler that immediately runs the rejected thread - this handler is not recommended if you need to message between threads and/or there are common dependencies. Also, notice that this handler will run onThreadsPooling
thread, blocking any other calls.
-
-
Constructor Summary
Constructors Constructor Description ImmediatelyRunOnRejectedExecutionHandler()
Default only available constructor.
-
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
-
-