Class BlockingRejectedExecutionHandler

  • All Implemented Interfaces:
    RejectedExecutionHandler

    public class BlockingRejectedExecutionHandler
    extends Object
    implements RejectedExecutionHandler
    This is a component to optionally configure a ThreadPoolTaskExecutor. The purpose of this is that, when the task queue is full, rather than rejecting another task, it delegates to the calling thread to execute.

    Care should be taken as this can cause thread starvation, but the trade-off is that when you have a task executor with a max queue size, it allows you to throttle so that you don't either run out of memory filling an unbounded queue, or get an exception because the queue was full.

    Author:
    Kelly Tisdell (ktisdell)