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

## rabbit.util
Class ThreadPool<T>

    java.lang.Object
      rabbit.util.ThreadPool<T>

    public class ThreadPool<T>

extends java.lang.Object

This is a thread pool. It uses RestartableThread.

Nested Class Summary
`static class` | `ThreadPool.Usage` The current usage of the threadpool

Constructor Summary
`ThreadPool(RestartableThreadFactory<T> tf, int limit)` Create a ThreadPool.

Method Summary
`RestartableThreadFactory` | `getFactory()` Get the current factory.
`int` | `getLimit()` Get the current limit of concurrent threads.
`T` | `getThread()` Get a Thread.
`ThreadPool.Usage` | `getUsage()` Get the current usage of this thread pool.
`void` | `returnThread(T t)` Return a thread to the pool.
`void` | `setFactory(RestartableThreadFactory<T> tf)` Set the factory to use for creating threads.
`void` | `setLimit(int limit)` Set the limit.

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

Constructor Detail

### ThreadPool

    public ThreadPool(RestartableThreadFactory<T> tf,
                      int limit)

  Create a ThreadPool.

  Parameters:
    `tf` - the RestartableThreadFactory that is used as more Threads are needed.
    `limit` - dont create more threads than this.

Method Detail

### setLimit

    public void setLimit(int limit)

  Set the limit.

  Parameters:
    `limit` - the new limit of concurrent threads.

### getLimit

    public int getLimit()

  Get the current limit of concurrent threads.

  Returns:
    the limit of threads.

### getThread

    public T getThread()

  Get a Thread. This will wait for a thread to be returned if the limit is currently reached.

### returnThread

    public void returnThread(T t)

  Return a thread to the pool. If the thread was never part of this pool it will be ignored.

  Parameters:
    `t` - the thread to return.

### setFactory

    public void setFactory(RestartableThreadFactory<T> tf)

  Set the factory to use for creating threads.

  Parameters:
    `tf` - the new factory.

### getFactory

    public RestartableThreadFactory getFactory()

  Get the current factory.

  Returns:
    the current factory.

### getUsage

    public ThreadPool.Usage getUsage()

  Get the current usage of this thread pool.

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