RejectedExecutionHandler


RejectedExecutionHandler java.util.concurrent

Java 5.0

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( )



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net