Name
RejectedExecutionHandler
Synopsis
This interface defines an API for a handler
method invoked by a ThreadPoolExecutor when its
execute( ) method cannot accept any more
Runnable objects. This can occur when both the
thread pool and the queue of waiting tasks is full, or when the
ThreadPoolExecutor has been shut down. Register an
instance of this class with the setRejectedExecutionHandler(
) method of ThreadPoolExecutor.
ThreadPoolExecutor includes several predefined
implementations of this interface as static member classes. If the
rejectedExecution( ) method cannot arrange for the
Runnable to be run and does not wish to simply
discard that task, it should throw a
RejectedExecutionException which propagates up to
the caller that submitted the task for execution.
public interface RejectedExecutionHandler { // Public Instance Methods void rejectedExecution(Runnable r, ThreadPoolExecutor executor); }
Implementations
ThreadPoolExecutor.AbortPolicy,
ThreadPoolExecutor.CallerRunsPolicy,
ThreadPoolExecutor.DiscardOldestPolicy,
ThreadPoolExecutor.DiscardPolicy
Passed To
ScheduledThreadPoolExecutor.ScheduledThreadPoolExecutor(
),
ThreadPoolExecutor.{setRejectedExecutionHandler(
), ThreadPoolExecutor( )}
Returned By
ThreadPoolExecutor.getRejectedExecutionHandler( )
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access