com.mongodb.util
Class ThreadPool<T>

java.lang.Object
  extended by com.mongodb.util.ThreadPool<T>

public abstract class ThreadPool<T>
extends java.lang.Object


Constructor Summary
ThreadPool(java.lang.String name, int numThreads)
          Initializes a new thread pool with a given name and number of threads.
ThreadPool(java.lang.String name, int numThreads, int maxQueueSize)
          Initializes a new thread pool with a given name, number of threads, and queue size.
 
Method Summary
abstract  void handle(T t)
          Handles a given object.
abstract  void handleError(T t, java.lang.Exception e)
          Handles a given object and exception.
 int inProgress()
           
 int numThreads()
           
 boolean offer(T t)
          Adds a new object to the pool, if possible.
 int queueSize()
          Returns the size of the pool's queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadPool

public ThreadPool(java.lang.String name,
                  int numThreads)
Initializes a new thread pool with a given name and number of threads.

Parameters:
name - identifying name
numThreads - the number of threads allowed in the pool

ThreadPool

public ThreadPool(java.lang.String name,
                  int numThreads,
                  int maxQueueSize)
Initializes a new thread pool with a given name, number of threads, and queue size.

Parameters:
name - identifying name
numThreads - the number of threads allowed in the pool
maxQueueSize - the size of the pool entry queue
Method Detail

handle

public abstract void handle(T t)
                     throws java.lang.Exception
Handles a given object.

Parameters:
t - the object to handle
Throws:
java.lang.Exception

handleError

public abstract void handleError(T t,
                                 java.lang.Exception e)
Handles a given object and exception.

Parameters:
t - the object to handle
e - the exception to handle

queueSize

public int queueSize()
Returns the size of the pool's queue.

Returns:
pool size

offer

public boolean offer(T t)
Adds a new object to the pool, if possible.

Parameters:
t - the object to be added
Returns:
if the object was successfully added

inProgress

public int inProgress()

numThreads

public int numThreads()