uPortal 2.4.1
API Documentation

org.jasig.portal.utils.threading
Class AbstractPool

java.lang.Object
  extended byorg.jasig.portal.utils.threading.AbstractPool
All Implemented Interfaces:
ThreadPool
Direct Known Subclasses:
BoundedThreadPool

public abstract class AbstractPool
extends java.lang.Object
implements ThreadPool

An abstract implementation of the ThreadPool interface which implements the totalThreads(), idleThreads(), signalThreadIdle(), signalThreadWorking(), and destroy() methods.

Version:
$Revision: 1.11 $
Author:
Constructor Summary
AbstractPool(int minThreads, int maxThreads, int threadPriority)
          AbstractPool Construcutor
 
Method Summary
 int busyThreads()
          Gives the number of busy (working) worker threads in the pool
 void destroy()
          Destroys the pool and all it's threads.
abstract  void destroyThread(java.lang.Thread thread)
          Destroys the pooled thread
abstract  WorkTracker execute(WorkerTask task)
          Queues up a task to be executed.
 java.lang.Thread getPooledThread()
          Gets the thread from the pool
 int idleThreads()
          Gives the number of idle threads in the pool
 void lockThread(java.lang.Thread thread)
          Locks the thread for running
 void releaseThread(java.lang.Thread thread)
          Releases the thread to the pool
 int totalThreads()
          Gives the total number of threads in the pool
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPool

public AbstractPool(int minThreads,
                    int maxThreads,
                    int threadPriority)
AbstractPool Construcutor

Parameters:
minThreads - the min number of worker threads that can be in this pool
maxThreads - the max number of worker threads that can be in this pool
threadPriority - the priority these worker threads should have
Method Detail

execute

public abstract WorkTracker execute(WorkerTask task)
                             throws java.lang.IllegalStateException
Queues up a task to be executed. The queue use FIFO ordering.

Specified by:
execute in interface ThreadPool
Parameters:
task - the task to be executed
Returns:
the WorkerTracker for used to track and interact with this task
Throws:
java.lang.IllegalStateException - - thrown if the pool has been destroyed

destroyThread

public abstract void destroyThread(java.lang.Thread thread)
Destroys the pooled thread

Specified by:
destroyThread in interface ThreadPool
Parameters:
thread - the thread to be destroyed

destroy

public void destroy()
Destroys the pool and all it's threads. A destroyed pool thread can not be used after is has been destroyed. Threads running when a pool is destroyed are interrupted and then destroyed.

Specified by:
destroy in interface ThreadPool

totalThreads

public int totalThreads()
                 throws java.lang.IllegalStateException
Gives the total number of threads in the pool

Specified by:
totalThreads in interface ThreadPool
Returns:
the total number of worker threads (busy and idle) in the pool
Throws:
java.lang.IllegalStateException

idleThreads

public int idleThreads()
                throws java.lang.IllegalStateException
Gives the number of idle threads in the pool

Specified by:
idleThreads in interface ThreadPool
Returns:
the number of idle worker threads in the pool
Throws:
java.lang.IllegalStateException

busyThreads

public int busyThreads()
                throws java.lang.IllegalStateException
Gives the number of busy (working) worker threads in the pool

Specified by:
busyThreads in interface ThreadPool
Returns:
the number of busy workers in the pool
Throws:
java.lang.IllegalStateException

releaseThread

public void releaseThread(java.lang.Thread thread)
                   throws java.lang.Exception
Releases the thread to the pool

Specified by:
releaseThread in interface ThreadPool
Parameters:
thread - the thread to be released
Throws:
java.lang.Exception

lockThread

public void lockThread(java.lang.Thread thread)
                throws java.lang.Exception
Locks the thread for running

Specified by:
lockThread in interface ThreadPool
Parameters:
thread - the thread to be locked
Throws:
java.lang.Exception

getPooledThread

public java.lang.Thread getPooledThread()
                                 throws java.lang.Exception
Gets the thread from the pool

Specified by:
getPooledThread in interface ThreadPool
Returns:
a pooled thread
Throws:
java.lang.Exception

uPortal 2.4.1
API Documentation