org.openeai.threadpool
Class ThreadPoolImpl

java.lang.Object
  extended by org.openeai.threadpool.ThreadPoolImpl
All Implemented Interfaces:
ThreadPool

public class ThreadPoolImpl
extends java.lang.Object
implements ThreadPool


Constructor Summary
ThreadPoolImpl(java.util.Properties props)
           
ThreadPoolImpl(ThreadPoolConfig tConfig)
           
 
Method Summary
 void addJob(java.lang.Runnable job)
          Adds a 'job' to the ThreadPool to be executed in a Thread.
 boolean checkBeforeProcessing()
          Returns a flag indicating whether this ThreadPool should check itself before adding another job to the pool.
 int getJobsInProgress()
          Returns the number of jobs that are currently in progress for this ThreadPool.
 Stats getStats()
          Takes a "snapshot" of the threadpool at the current time and returns statistics.
 void shutdown()
          Sets a flag indicating that the ThreadPool is in a 'shutdown' status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadPoolImpl

public ThreadPoolImpl(ThreadPoolConfig tConfig)
               throws java.lang.NumberFormatException,
                      java.lang.IllegalArgumentException
Throws:
java.lang.NumberFormatException
java.lang.IllegalArgumentException

ThreadPoolImpl

public ThreadPoolImpl(java.util.Properties props)
               throws java.lang.NumberFormatException,
                      java.lang.IllegalArgumentException
Throws:
java.lang.NumberFormatException
java.lang.IllegalArgumentException
Method Detail

checkBeforeProcessing

public boolean checkBeforeProcessing()
Description copied from interface: ThreadPool
Returns a flag indicating whether this ThreadPool should check itself before adding another job to the pool. Based on this flag, if the thread pool can't find an idle thread and it can't create a new one because the maximum number of threads have already been allocated, it may or may not add the job to the list of "pending" jobs.

This is used to verify that the ThreadPool can actually accept and immediately process a job that's added via the addJob method. This is to reduce the number of potential jobs in memory in a "pending" state waiting for the ThreadPool to free up some idle threads.

Specified by:
checkBeforeProcessing in interface ThreadPool
Returns:
boolean true=make sure there's room in the pool before adding to the list of pending jobs.

shutdown

public void shutdown()
Sets a flag indicating that the ThreadPool is in a 'shutdown' status. No more jobs can be added to the pool when this happens.


addJob

public void addJob(java.lang.Runnable job)
            throws ThreadPoolException
Adds a 'job' to the ThreadPool to be executed in a Thread.

Specified by:
addJob in interface ThreadPool
Parameters:
job - java.lang.Runnable the job to be added to the ThreadPool
Throws:
- - ThreadPoolException if it has any problems adding the job to the ThreadPool.
ThreadPoolException
See Also:
ThreadPool.checkBeforeProcessing()

getStats

public Stats getStats()
Description copied from interface: ThreadPool
Takes a "snapshot" of the threadpool at the current time and returns statistics.

Specified by:
getStats in interface ThreadPool
Returns:
Stats
See Also:
Stats

getJobsInProgress

public int getJobsInProgress()
Description copied from interface: ThreadPool
Returns the number of jobs that are currently in progress for this ThreadPool.

Specified by:
getJobsInProgress in interface ThreadPool
Returns:
int the number of jobs in progress (available threads - idle threads)


Copyright © 2002,2003 OpenEAI Software Foundation