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:
  java.util.concurrent.Executor, java.util.concurrent.ExecutorService, LifeCycle, ThreadPool

    public class ThreadPool

extends java.util.concurrent.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
`java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy`

Nested classes/interfaces inherited from interface org.mortbay.component.LifeCycle
`LifeCycle.Listener`

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

Method Summary
`void` | `addLifeCycleListener(LifeCycle.Listener listener)`
`boolean` | `dispatch(java.lang.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` | `removeLifeCycleListener(LifeCycle.Listener listener)`
`void` | `start()` Starts the component.
`void` | `stop()` Stops the component.

Methods inherited from class java.util.concurrent.ThreadPoolExecutor
`afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, 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, newTaskFor, newTaskFor, 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 queueSize)

  Default constructor. Core size is 32, max pool size is 256, pool thread timeout after 60 seconds

  Parameters:
    `queueSize` - if -1, an unbounded `LinkedBlockingQueue` is used, if 0 then a `SynchronousQueue` is used, other a `ArrayBlockingQueue` of the given size is used.

### ThreadPool

    public ThreadPool(int corePoolSize,
                      int maximumPoolSize,
                      long keepAliveTime,
                      java.util.concurrent.TimeUnit unit)

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

### ThreadPool

    public ThreadPool(int corePoolSize,
                      int maximumPoolSize,
                      long keepAliveTime,
                      java.util.concurrent.TimeUnit unit,
                      java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue)

### ThreadPool

    public ThreadPool(int corePoolSize,
                      int maximumPoolSize,
                      long keepAliveTime,
                      java.util.concurrent.TimeUnit unit,
                      java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
                      java.util.concurrent.RejectedExecutionHandler handler)

### ThreadPool

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

### ThreadPool

    public ThreadPool(int corePoolSize,
                      int maximumPoolSize,
                      long keepAliveTime,
                      java.util.concurrent.TimeUnit unit,
                      java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
                      java.util.concurrent.ThreadFactory threadFactory)

Method Detail

### dispatch

    public boolean dispatch(java.lang.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 java.lang.InterruptedException

  Description copied from interface: `ThreadPool`
  Blocks until the thread pool is `stopped`.

  Specified by:
    `join` in interface `ThreadPool`
  Throws:
    `java.lang.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 java.lang.Exception

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

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

### stop

    public void stop()
              throws java.lang.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:
    `java.lang.Exception` - If the component fails to stop
  See Also:
    `LifeCycle.isStopped()`, `LifeCycle.start()`, `LifeCycle.isFailed()`

### addLifeCycleListener

    public void addLifeCycleListener(LifeCycle.Listener listener)

  Specified by:
    `addLifeCycleListener` in interface `LifeCycle`

### removeLifeCycleListener

    public void removeLifeCycleListener(LifeCycle.Listener listener)

  Specified by:
    `removeLifeCycleListener` in interface `LifeCycle`

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 © 1995-2010 Mort Bay Consulting. All Rights Reserved.