org.opengts.util
Class ThreadPool

java.lang.Object
  extended by org.opengts.util.ThreadPool

public class ThreadPool
extends java.lang.Object

Thread pool manager


Field Summary
static int STOP_NEVER
           
static int STOP_NOW
           
static int STOP_WAITING
           
 
Constructor Summary
ThreadPool(java.lang.String name)
          Constuctor
ThreadPool(java.lang.String name, int maxPoolSize)
          Constructor
 
Method Summary
protected  void _removeThread(org.opengts.util.ThreadPool.ThreadJob thread)
          Removes the specified worker thread from the pool
 boolean equals(java.lang.Object other)
          Returns true if this object is equal to other.
 int getMaxSize()
          Gets the maximum size of this thread pool
 java.lang.String getName()
          Gets the name of the thread pool
 int getSize()
          Gets the current size of this thread pool
 java.lang.ThreadGroup getThreadGroup()
          Gets the thread group of the Threads in this pool
static void main(java.lang.String[] argv)
          Main entry point for testing/debugging
 void run(java.lang.Runnable job)
          Adds a new job to the thread pool's queue
 void setMaxSize(int maxSize)
          Sets the maximum size of this thread pool
 void stopThreads()
          Stops all threads in this pool once queued jobs are complete
 java.lang.String toString()
          Returns the name of the thread pool
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STOP_WAITING

public static final int STOP_WAITING
See Also:
Constant Field Values

STOP_NEVER

public static final int STOP_NEVER
See Also:
Constant Field Values

STOP_NOW

public static final int STOP_NOW
See Also:
Constant Field Values
Constructor Detail

ThreadPool

public ThreadPool(java.lang.String name)
Constuctor

Parameters:
name - The name of the thread pool

ThreadPool

public ThreadPool(java.lang.String name,
                  int maxPoolSize)
Constructor

Parameters:
name - The name of the thread pool
maxPoolSize - The maximum number of threads in the thread pool[CHECK]
Method Detail

getName

public java.lang.String getName()
Gets the name of the thread pool

Returns:
The name of the thread pool

toString

public java.lang.String toString()
Returns the name of the thread pool

Overrides:
toString in class java.lang.Object
Returns:
The name of the thread pool

equals

public boolean equals(java.lang.Object other)
Returns true if this object is equal to other. This will only return true if they are the same object

Overrides:
equals in class java.lang.Object
Parameters:
other - The object to check equality with
Returns:
True if other is the same object

getThreadGroup

public java.lang.ThreadGroup getThreadGroup()
Gets the thread group of the Threads in this pool

Returns:
The thread group of the Threads in this pool

getSize

public int getSize()
Gets the current size of this thread pool

Returns:
The number of thread jobs in this thread pool

setMaxSize

public void setMaxSize(int maxSize)
Sets the maximum size of this thread pool

Parameters:
maxSize - The maximum size of the thread pool

getMaxSize

public int getMaxSize()
Gets the maximum size of this thread pool

Returns:
The maximum size of the thread pool

run

public void run(java.lang.Runnable job)
Adds a new job to the thread pool's queue

Parameters:
job - The job to add to the queue

stopThreads

public void stopThreads()
Stops all threads in this pool once queued jobs are complete


_removeThread

protected void _removeThread(org.opengts.util.ThreadPool.ThreadJob thread)
Removes the specified worker thread from the pool

Parameters:
thread - The thread to remove from the pool

main

public static void main(java.lang.String[] argv)
Main entry point for testing/debugging

Parameters:
argv - Comand-line arguments