Class DelegatingThreadPool

All Implemented Interfaces:
Executor, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle, ThreadPool, TryExecutor

public class DelegatingThreadPool extends ContainerLifeCycle implements ThreadPool, TryExecutor
  • Field Details

  • Constructor Details

    • DelegatingThreadPool

      public DelegatingThreadPool(Executor executor)
  • Method Details

    • getExecutor

      public Executor getExecutor()
    • setExecutor

      public void setExecutor(Executor executor)
    • execute

      public void execute(Runnable job)
      Specified by:
      execute in interface Executor
      Specified by:
      execute in interface TryExecutor
    • tryExecute

      public boolean tryExecute(Runnable task)
      Description copied from interface: TryExecutor
      Attempt to execute a task.
      Specified by:
      tryExecute in interface TryExecutor
      Parameters:
      task - The task to be executed
      Returns:
      True IFF the task has been given directly to a thread to execute. The task cannot be queued pending the later availability of a Thread.
    • getIdleThreads

      public int getIdleThreads()
      Specified by:
      getIdleThreads in interface ThreadPool
      Returns:
      The number of idle threads in the pool
    • getThreads

      public int getThreads()
      Specified by:
      getThreads in interface ThreadPool
      Returns:
      The total number of threads currently in the pool
    • isLowOnThreads

      public boolean isLowOnThreads()
      Specified by:
      isLowOnThreads in interface ThreadPool
      Returns:
      True if the pool is low on threads
    • join

      public void join() throws InterruptedException
      Description copied from interface: ThreadPool
      Blocks until the thread pool is stopped.
      Specified by:
      join in interface ThreadPool
      Throws:
      InterruptedException - if thread was interrupted
    • doStop

      protected void doStop() throws Exception
      Description copied from class: ContainerLifeCycle
      Stops the managed lifecycle beans in the reverse order they were added.
      Overrides:
      doStop in class ContainerLifeCycle
      Throws:
      Exception