Class TaskQueue

All Implemented Interfaces:
Serializable, Iterable<Runnable>, Collection<Runnable>, BlockingQueue<Runnable>, Queue<Runnable>, RetryableQueue<Runnable>

public class TaskQueue extends LinkedBlockingQueue<Runnable> implements RetryableQueue<Runnable>
A task queue specifically designed to run with a thread pool executor. The task queue is optimised to properly utilize threads within a thread pool executor. A normal queue causes the executor to queue tasks first and only create new threads once the queue is full. This queue instead refuses to queue a task while all existing threads are busy and the pool size is below its maximum, so the executor creates a new thread for the task instead. It also supports forcing items onto the queue via force(Runnable).
See Also:
  • Field Details

    • sm

      protected static final StringManager sm
      The string manager for this package.
  • Constructor Details

    • TaskQueue

      public TaskQueue()
      Constructs a new TaskQueue with default capacity.
    • TaskQueue

      public TaskQueue(int capacity)
      Constructs a new TaskQueue with the given capacity.
      Parameters:
      capacity - the queue capacity
    • TaskQueue

      public TaskQueue(Collection<? extends Runnable> c)
      Constructs a new TaskQueue containing the elements in the given collection.
      Parameters:
      c - the collection of initial elements
  • Method Details