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

## org.mortbay.thread.concurrent
Class ThreadPool

    java.lang.Object
      java.util.concurrent.AbstractExecutorService
          java.util.concurrent.ThreadPoolExecutor
              org.mortbay.thread.concurrent.ThreadPool

All Implemented Interfaces:
  Executor, ExecutorService, LifeCycle, ThreadPool

    public class ThreadPool

extends ThreadPoolExecutor
implements ThreadPool, LifeCycle

Jetty ThreadPool using java 5 ThreadPoolExecutor This class wraps a `ThreadPoolExecutor` with the `ThreadPool` and `LifeCycle` interfaces so that it may be used by the Jetty `Server`

Author:
  gregw

Nested Class Summary

Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
`ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy`

Constructor Summary
`ThreadPool()` Default constructor.
`ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit)` Size constructor.
`ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)`
`ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)`
`ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)`
`ThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)`

Method Summary
`boolean` | `dispatch(Runnable job)`
`int` | `getIdleThreads()`
`int` | `getThreads()`
`boolean` | `isFailed()`
`boolean` | `isLowOnThreads()`
`boolean` | `isRunning()`
`boolean` | `isStarted()`
`boolean` | `isStarting()`
`boolean` | `isStopped()`
`boolean` | `isStopping()`
`void` | `join()` Blocks until the thread pool is `stopped`.
`void` | `start()` Starts the component.
`void` | `stop()` Stops the component.

Methods inherited from class java.util.concurrent.ThreadPoolExecutor
`afterExecute, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated`

Methods inherited from class java.util.concurrent.AbstractExecutorService
`invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit`

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

Constructor Detail

### ThreadPool

    public ThreadPool()

  Default constructor. Core size is 32, max pool size is 256, pool thread timeout after 60 seconds and an unbounded `LinkedBlockingQueue` is used for the job queue;

### ThreadPool

    public ThreadPool(int corePoolSize,
                      int maximumPoolSize,
                      long keepAliveTime,
                      TimeUnit unit)

  Size constructor. an unbounded `LinkedBlockingQueue` is used for the jobs queue;

### ThreadPool

    public ThreadPool(int corePoolSize,
                      int maximumPoolSize,
                      long keepAliveTime,
                      TimeUnit unit,
                      BlockingQueue<Runnable> workQueue)

### ThreadPool

    public ThreadPool(int corePoolSize,
                      int maximumPoolSize,
                      long keepAliveTime,
                      TimeUnit unit,
                      BlockingQueue<Runnable> workQueue,
                      RejectedExecutionHandler handler)

### ThreadPool

    public ThreadPool(int corePoolSize,
                      int maximumPoolSize,
                      long keepAliveTime,
                      TimeUnit unit,
                      BlockingQueue<Runnable> workQueue,
                      ThreadFactory threadFactory,
                      RejectedExecutionHandler handler)

### ThreadPool

    public ThreadPool(int corePoolSize,
                      int maximumPoolSize,
                      long keepAliveTime,
                      TimeUnit unit,
                      BlockingQueue<Runnable> workQueue,
                      ThreadFactory threadFactory)

Method Detail

### dispatch

    public boolean dispatch(Runnable job)

  Specified by:
    `dispatch` in interface `ThreadPool`

### 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`

### isFailed

    public boolean isFailed()

  Specified by:
    `isFailed` in interface `LifeCycle`
  Returns:
    true if the component has failed to start or has failed to stop.

### isRunning

    public boolean isRunning()

  Specified by:
    `isRunning` in interface `LifeCycle`
  Returns:
    true if the component is starting or has been started.

### isStarted

    public boolean isStarted()

  Specified by:
    `isStarted` in interface `LifeCycle`
  Returns:
    true if the component has been started.
  See Also:
    `LifeCycle.start()`, `LifeCycle.isStarting()`

### isStarting

    public boolean isStarting()

  Specified by:
    `isStarting` in interface `LifeCycle`
  Returns:
    true if the component is starting.
  See Also:
    `LifeCycle.isStarted()`

### isStopped

    public boolean isStopped()

  Specified by:
    `isStopped` in interface `LifeCycle`
  Returns:
    true if the component has been stopped.
  See Also:
    `LifeCycle.stop()`, `LifeCycle.isStopping()`

### isStopping

    public boolean isStopping()

  Specified by:
    `isStopping` in interface `LifeCycle`
  Returns:
    true if the component is stopping.
  See Also:
    `LifeCycle.isStopped()`

### start

    public void start()
               throws Exception

  Description copied from interface: `LifeCycle`
  Starts the component.

  Specified by:
    `start` in interface `LifeCycle`
  Throws:
    `Exception` - If the component fails to start
  See Also:
    `LifeCycle.isStarted()`, `LifeCycle.stop()`, `LifeCycle.isFailed()`

### stop

    public void stop()
              throws Exception

  Description copied from interface: `LifeCycle`
  Stops the component. The component may wait for current activities to complete normally, but it can be interrupted.

  Specified by:
    `stop` in interface `LifeCycle`
  Throws:
    `Exception` - If the component fails to stop
  See Also:
    `LifeCycle.isStopped()`, `LifeCycle.start()`, `LifeCycle.isFailed()`

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

Copyright © 2007 Mort Bay Consulting. All Rights Reserved.