nxt.util

## Class QueuedThreadPool

- java.lang.Object
- - java.util.concurrent.AbstractExecutorService
  - - java.util.concurrent.ThreadPoolExecutor
    - - nxt.util.QueuedThreadPool

- All Implemented Interfaces:
    java.util.concurrent.Executor, java.util.concurrent.ExecutorService

      public class QueuedThreadPool
      extends java.util.concurrent.ThreadPoolExecutor

  QueuedThreadPool creates threads to process requests until the maximum pool size is reached. Additional requests are queued until a thread becomes available. Threads that are idle for 60 seconds are terminated if the pool size is greater than the core size.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor

      `java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueuedThreadPool(int coreSize, int maxSize)` Create the queued thread pool

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `afterExecute(java.lang.Runnable task, java.lang.Throwable exc)` Process task completion
    `void` | `execute(java.lang.Runnable task)` Execute a task
    `int` | `getCorePoolSize()` Return the core pool size
    `int` | `getMaximumPoolSize()` Return the maximum pool size
    `void` | `setCorePoolSize(int coreSize)` Set the core pool size
    `void` | `setMaximumPoolSize(int maxSize)` Set the maximum pool size
    `<T> java.util.concurrent.Future<T>` | `submit(java.util.concurrent.Callable<T> callable)` Submit a task for execution
    `java.util.concurrent.Future<?>` | `submit(java.lang.Runnable task)` Submit a task for execution
    `<T> java.util.concurrent.Future<T>` | `submit(java.lang.Runnable task, T result)` Submit a task for execution

    - ### Methods inherited from class java.util.concurrent.ThreadPoolExecutor

      `allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getKeepAliveTime, getLargestPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setKeepAliveTime, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated, toString`

    - ### Methods inherited from class java.util.concurrent.AbstractExecutorService

      `invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### QueuedThreadPool

          public QueuedThreadPool(int coreSize,
                                  int maxSize)

      Create the queued thread pool
      Parameters:
        `coreSize` - Core pool size
        `maxSize` - Maximum pool size

  - ### Method Detail

    - #### getCorePoolSize

          public int getCorePoolSize()

      Return the core pool size
      Overrides:
        `getCorePoolSize` in class `java.util.concurrent.ThreadPoolExecutor`
      Returns:
        Core pool size

    - #### setCorePoolSize

          public void setCorePoolSize(int coreSize)

      Set the core pool size
      Overrides:
        `setCorePoolSize` in class `java.util.concurrent.ThreadPoolExecutor`
      Parameters:
        `coreSize` - Core pool size

    - #### getMaximumPoolSize

          public int getMaximumPoolSize()

      Return the maximum pool size
      Overrides:
        `getMaximumPoolSize` in class `java.util.concurrent.ThreadPoolExecutor`
      Returns:
        Maximum pool size

    - #### setMaximumPoolSize

          public void setMaximumPoolSize(int maxSize)

      Set the maximum pool size
      Overrides:
        `setMaximumPoolSize` in class `java.util.concurrent.ThreadPoolExecutor`
      Parameters:
        `maxSize` - Maximum pool size

    - #### execute

          public void execute(java.lang.Runnable task)
                       throws java.util.concurrent.RejectedExecutionException

      Execute a task
      Specified by:
        `execute` in interface `java.util.concurrent.Executor`
      Overrides:
        `execute` in class `java.util.concurrent.ThreadPoolExecutor`
      Parameters:
        `task` - Task
      Throws:
        `java.util.concurrent.RejectedExecutionException` - Unable to execute task

    - #### submit

          public java.util.concurrent.Future<?> submit(java.lang.Runnable task)
                                                throws java.util.concurrent.RejectedExecutionException

      Submit a task for execution
      Specified by:
        `submit` in interface `java.util.concurrent.ExecutorService`
      Overrides:
        `submit` in class `java.util.concurrent.AbstractExecutorService`
      Parameters:
        `task` - Runnable task
      Returns:
        Future representing the task
      Throws:
        `java.util.concurrent.RejectedExecutionException` - Unable to execute task

    - #### submit

          public <T> java.util.concurrent.Future<T> submit(java.lang.Runnable task,
                                                           T result)
                                                    throws java.util.concurrent.RejectedExecutionException

      Submit a task for execution
      Specified by:
        `submit` in interface `java.util.concurrent.ExecutorService`
      Overrides:
        `submit` in class `java.util.concurrent.AbstractExecutorService`
      Type Parameters:
        `T` - Result type
      Parameters:
        `task` - Runnable task
        `result` - Result returned when task completes
      Returns:
        Future representing the task result
      Throws:
        `java.util.concurrent.RejectedExecutionException` - Unable to execute task

    - #### submit

          public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> callable)
                                                    throws java.util.concurrent.RejectedExecutionException

      Submit a task for execution
      Specified by:
        `submit` in interface `java.util.concurrent.ExecutorService`
      Overrides:
        `submit` in class `java.util.concurrent.AbstractExecutorService`
      Type Parameters:
        `T` - Result type
      Parameters:
        `callable` - Callable task
      Returns:
        Future representing the task
      Throws:
        `java.util.concurrent.RejectedExecutionException` - Unable to execute task

    - #### afterExecute

          protected void afterExecute(java.lang.Runnable task,
                                      java.lang.Throwable exc)

      Process task completion
      Overrides:
        `afterExecute` in class `java.util.concurrent.ThreadPoolExecutor`
      Parameters:
        `task` - Runnable task
        `exc` - Thrown exception