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
Class BoundedThreadPool

    java.lang.Object
      org.mortbay.component.AbstractLifeCycle
          org.mortbay.thread.BoundedThreadPool

All Implemented Interfaces:
  Serializable, LifeCycle, ThreadPool

Direct Known Subclasses:
  IO

Deprecated. Use `QueuedThreadPool`

    public class BoundedThreadPool

extends AbstractLifeCycle
implements Serializable, ThreadPool

A pool of threads.

Avoids the expense of thread creation by pooling threads after their run methods exit for reuse.

If the maximum pool size is reached, jobs wait for a free thread. By default there is no maximum pool size. Idle threads timeout and terminate until the minimum number of threads are running.

Author:
  Greg Wilkins , Juancarlo Anez
See Also:
  Serialized Form

Nested Class Summary
`class` | `BoundedThreadPool.PoolThread` Deprecated. Pool Thread class.

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

Field Summary

Fields inherited from class org.mortbay.component.AbstractLifeCycle
`_listeners`

Constructor Summary
`BoundedThreadPool()` Deprecated.

Method Summary
`boolean` | `dispatch(Runnable job)` Deprecated. Run job.
`protected void` | `doStart()` Deprecated.
`protected void` | `doStop()` Deprecated. Stop the BoundedThreadPool.
`int` | `getIdleThreads()` Deprecated. Get the number of idle threads in the pool.
`int` | `getLowThreads()` Deprecated.
`int` | `getMaxIdleTimeMs()` Deprecated. Get the maximum thread idle time.
`int` | `getMaxThreads()` Deprecated. Set the maximum number of threads.
`int` | `getMinThreads()` Deprecated. Get the minimum number of threads.
`String` | `getName()` Deprecated.
`int` | `getQueueSize()` Deprecated.
`int` | `getThreads()` Deprecated. Get the number of threads in the pool.
`int` | `getThreadsPriority()` Deprecated. Get the priority of the pool threads.
`boolean` | `isDaemon()` Deprecated. Delegated to the named or anonymous Pool.
`boolean` | `isLowOnThreads()` Deprecated.
`void` | `join()` Deprecated. Blocks until the thread pool is `stopped`.
`protected BoundedThreadPool.PoolThread` | `newThread(Runnable job)` Deprecated.
`void` | `setDaemon(boolean daemon)` Deprecated. Delegated to the named or anonymous Pool.
`void` | `setLowThreads(int lowThreads)` Deprecated.
`void` | `setMaxIdleTimeMs(int maxIdleTimeMs)` Deprecated. Set the maximum thread idle time.
`void` | `setMaxThreads(int maxThreads)` Deprecated. Set the maximum number of threads.
`void` | `setMinThreads(int minThreads)` Deprecated. Set the minimum number of threads.
`void` | `setName(String name)` Deprecated.
`void` | `setThreadsPriority(int priority)` Deprecated. Set the priority of the pool threads.
`protected void` | `stopJob(Thread thread, Object job)` Deprecated. Stop a Job.

Methods inherited from class org.mortbay.component.AbstractLifeCycle
`addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

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

Constructor Detail

### BoundedThreadPool

    public BoundedThreadPool()

  Deprecated.

Method Detail

### dispatch

    public boolean dispatch(Runnable job)

  Deprecated.
  Run job.

  Specified by:
    `dispatch` in interface `ThreadPool`
  Returns:
    true

### getIdleThreads

    public int getIdleThreads()

  Deprecated.
  Get the number of idle threads in the pool.

  Specified by:
    `getIdleThreads` in interface `ThreadPool`
  Returns:
    Number of threads
  See Also:
    `getThreads()`

### getLowThreads

    public int getLowThreads()

  Deprecated.
  Returns:
    low resource threads threshhold

### getMaxIdleTimeMs

    public int getMaxIdleTimeMs()

  Deprecated.
  Get the maximum thread idle time. Delegated to the named or anonymous Pool.

  Returns:
    Max idle time in ms.
  See Also:
    `setMaxIdleTimeMs(int)`

### getMaxThreads

    public int getMaxThreads()

  Deprecated.
  Set the maximum number of threads. Delegated to the named or anonymous Pool.

  Returns:
    maximum number of threads.
  See Also:
    `setMaxThreads(int)`

### getMinThreads

    public int getMinThreads()

  Deprecated.
  Get the minimum number of threads. Delegated to the named or anonymous Pool.

  Returns:
    minimum number of threads.
  See Also:
    `setMinThreads(int)`

### getName

    public String getName()

  Deprecated.
  Returns:
    The name of the BoundedThreadPool.

### getThreads

    public int getThreads()

  Deprecated.
  Get the number of threads in the pool.

  Specified by:
    `getThreads` in interface `ThreadPool`
  Returns:
    Number of threads
  See Also:
    `getIdleThreads()`

### getThreadsPriority

    public int getThreadsPriority()

  Deprecated.
  Get the priority of the pool threads.

  Returns:
    the priority of the pool threads.

### getQueueSize

    public int getQueueSize()

  Deprecated.

### isDaemon

    public boolean isDaemon()

  Deprecated.
  Delegated to the named or anonymous Pool.

### isLowOnThreads

    public boolean isLowOnThreads()

  Deprecated.
  Specified by:
    `isLowOnThreads` in interface `ThreadPool`
  Returns:
    True if the pool is low on threads

### join

    public void join()
              throws InterruptedException

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

  Specified by:
    `join` in interface `ThreadPool`
  Throws:
    `InterruptedException`

### setDaemon

    public void setDaemon(boolean daemon)

  Deprecated.
  Delegated to the named or anonymous Pool.

### setLowThreads

    public void setLowThreads(int lowThreads)

  Deprecated.
  Parameters:
    `lowThreads` - low resource threads threshhold

### setMaxIdleTimeMs

    public void setMaxIdleTimeMs(int maxIdleTimeMs)

  Deprecated.
  Set the maximum thread idle time. Threads that are idle for longer than this period may be stopped. Delegated to the named or anonymous Pool.

  Parameters:
    `maxIdleTimeMs` - Max idle time in ms.
  See Also:
    `getMaxIdleTimeMs()`

### setMaxThreads

    public void setMaxThreads(int maxThreads)

  Deprecated.
  Set the maximum number of threads. Delegated to the named or anonymous Pool.

  Parameters:
    `maxThreads` - maximum number of threads.
  See Also:
    `getMaxThreads()`

### setMinThreads

    public void setMinThreads(int minThreads)

  Deprecated.
  Set the minimum number of threads. Delegated to the named or anonymous Pool.

  Parameters:
    `minThreads` - minimum number of threads
  See Also:
    `getMinThreads()`

### setName

    public void setName(String name)

  Deprecated.
  Parameters:
    `name` - Name of the BoundedThreadPool to use when naming Threads.

### setThreadsPriority

    public void setThreadsPriority(int priority)

  Deprecated.
  Set the priority of the pool threads.

  Parameters:
    `priority` - the new thread priority.

### doStart

    protected void doStart()
                    throws Exception

  Deprecated.
  Overrides:
    `doStart` in class `AbstractLifeCycle`
  Throws:
    `Exception`

### doStop

    protected void doStop()
                   throws Exception

  Deprecated.
  Stop the BoundedThreadPool. New jobs are no longer accepted,idle threads are interrupted and stopJob is called on active threads. The method then waits min(getMaxStopTimeMs(),getMaxIdleTimeMs()), for all jobs to stop, at which time killJob is called.

  Overrides:
    `doStop` in class `AbstractLifeCycle`
  Throws:
    `Exception`

### newThread

    protected BoundedThreadPool.PoolThread newThread(Runnable job)

  Deprecated.

### stopJob

    protected void stopJob(Thread thread,
                           Object job)

  Deprecated.
  Stop a Job. This method is called by the Pool if a job needs to be stopped. The default implementation does nothing and should be extended by a derived thread pool class if special action is required.

  Parameters:
    `thread` - The thread allocated to the job, or null if no thread allocated.
    `job` - The job object passed to run.

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-2008 Mort Bay Consulting. All Rights Reserved.