Class QueuedExecutorService

  • All Implemented Interfaces:
    Executor, ExecutorService
    Direct Known Subclasses:
    QueuedScheduledExecutorService

    public class QueuedExecutorService
    extends AbstractExecutorService
    Queues tasks and delegates them to a Executor in order.

    The resulting behavior is similar to a single threaded pool: Tasks submitted to this class are guaranteed to be executed in the same order as they were submitted, but potentially are executed by different threads of the delegate executor.

    The typical use case is, that you share a single ThreadPoolExecutor among multiple instances of this class, which results in a low overall thread count (only the ones spawned by the delegate executor), but still have the in-order execution behavior of a single threaded pool.

    • Constructor Detail

      • QueuedExecutorService

        public QueuedExecutorService​(Executor delegate)
        Parameters:
        delegate - the executor that will handle the tasks
    • Method Detail

      • execute

        public void execute​(Runnable command)
      • shutdown

        public void shutdown()
      • isShutdown

        public boolean isShutdown()
      • isTerminated

        public boolean isTerminated()