org.modeshape.common.util

## Interface ThreadPoolFactory

- All Known Implementing Classes:
    ExecutionContext, ThreadPools

      public interface ThreadPoolFactory

  Factory interface for creating/obtaining named thread pools.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ExecutorService` | `getCachedTreadPool(String name)` Signal that the supplied thread pool is no longer needed.
    `ScheduledExecutorService` | `getScheduledThreadPool(String name)` Obtain a scheduled thread pool with the supplied name, or create and return one if no thread pool exists with that name.
    `ExecutorService` | `getThreadPool(String name)` Obtain a thread pool with the supplied name, or create and return one if no thread pool exists with that name.
    `void` | `releaseThreadPool(ExecutorService pool)` Performs a `ExecutorService.shutdownNow()` on the given pool, if the pool has been created previously by this class.
    `void` | `terminateAllPools(long maxWaitTime, TimeUnit timeUnit)` Terminates all the existing thread pool, by waiting for them maximum `maxWaitTimeMillis` milliseconds, after which calling `ExecutorService.shutdownNow()`.

- - ### Method Detail

    - #### getThreadPool

          ExecutorService getThreadPool(String name)

      Obtain a thread pool with the supplied name, or create and return one if no thread pool exists with that name. When finished with the thread pool, it should be `released`.
      Parameters:
        `name` - the name of the thread pool; may not be null
      Returns:
        the thread pool executor; never null

    - #### getCachedTreadPool

          ExecutorService getCachedTreadPool(String name)

      Signal that the supplied thread pool is no longer needed. Obtain a cached thread pool with the supplied name, or create and return one if no thread pool exists with that name. When finished with the thread pool, it should be `released`.
      Parameters:
        `name` - the name of the thread pool; may not be null
      Returns:
        the thread pool executor; never null

    - #### getScheduledThreadPool

          ScheduledExecutorService getScheduledThreadPool(String name)

      Obtain a scheduled thread pool with the supplied name, or create and return one if no thread pool exists with that name. When finished with the thread pool, it should be `released`.
      Parameters:
        `name` - the name of the thread pool; may not be null
      Returns:
        the thread pool executor; never null

    - #### releaseThreadPool

          void releaseThreadPool(ExecutorService pool)

      Performs a `ExecutorService.shutdownNow()` on the given pool, if the pool has been created previously by this class. Clients which use this method should handle, if necessary, any potential `InterruptedException`
      Parameters:
        `pool` - the pool that is no longer needed

    - #### terminateAllPools

          void terminateAllPools(long maxWaitTime,
                               TimeUnit timeUnit)

      Terminates all the existing thread pool, by waiting for them maximum `maxWaitTimeMillis` milliseconds, after which calling `ExecutorService.shutdownNow()`.
      Parameters:
        `maxWaitTime` - the maximum amount of time that should be given to the pools to shutdown on their own; must be non-negative
        `timeUnit` - the unit of time for the `maxWaitTime` parameter

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.