Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Beta3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.common.util
Class ThreadPools

    java.lang.Object
      org.modeshape.common.util.ThreadPools

All Implemented Interfaces:
  ThreadPoolFactory

    @ThreadSafe
    public class ThreadPools

extends Object
implements ThreadPoolFactory

A simple `ThreadPoolFactory` implementation.

Constructor Summary
`ThreadPools()`

Method Summary
`ExecutorService` | `getCachedTreadPool(String name)` Signal that the supplied thread pool is no longer needed.
`ExecutorService` | `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 executor)` Performs a `ExecutorService.shutdownNow()` on the given pool, if the pool has been created previously by this class.
`void` | `terminateAllPools(long maxWaitTime, TimeUnit unit)` Terminates all the existing thread pool, by waiting for them maximum `maxWaitTimeMillis` milliseconds, after which calling `ExecutorService.shutdownNow()`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ThreadPools

    public ThreadPools()

Method Detail

### getThreadPool

    public ExecutorService getThreadPool(String name)

  Description copied from interface: `ThreadPoolFactory`
  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`.

  Specified by:
    `getThreadPool` in interface `ThreadPoolFactory`
  Parameters:
    `name` - the name of the thread pool; may not be null
  Returns:
    the thread pool executor; never null

### getCachedTreadPool

    public ExecutorService getCachedTreadPool(String name)

  Description copied from interface: `ThreadPoolFactory`
  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`.

  Specified by:
    `getCachedTreadPool` in interface `ThreadPoolFactory`
  Parameters:
    `name` - the name of the thread pool; may not be null
  Returns:
    the thread pool executor; never null

### getScheduledThreadPool

    public ExecutorService getScheduledThreadPool(String name)

  Description copied from interface: `ThreadPoolFactory`
  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`.

  Specified by:
    `getScheduledThreadPool` in interface `ThreadPoolFactory`
  Parameters:
    `name` - the name of the thread pool; may not be null
  Returns:
    the thread pool executor; never null

### releaseThreadPool

    public void releaseThreadPool(ExecutorService executor)

  Description copied from interface: `ThreadPoolFactory`
  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`

  Specified by:
    `releaseThreadPool` in interface `ThreadPoolFactory`
  Parameters:
    `executor` - the pool that is no longer needed

### terminateAllPools

    public void terminateAllPools(long maxWaitTime,
                                  TimeUnit unit)

  Description copied from interface: `ThreadPoolFactory`
  Terminates all the existing thread pool, by waiting for them maximum `maxWaitTimeMillis` milliseconds, after which calling `ExecutorService.shutdownNow()`.

  Specified by:
    `terminateAllPools` in interface `ThreadPoolFactory`
  Parameters:
    `maxWaitTime` - the maximum amount of time that should be given to the pools to shutdown on their own; must be non-negative
    `unit` - the unit of time for the `maxWaitTime` parameter

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Beta3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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