org.jpos.util
Class ThreadPool
java.lang.Object
java.lang.ThreadGroup
org.jpos.util.ThreadPool
- All Implemented Interfaces:
- java.lang.Thread.UncaughtExceptionHandler, Configurable, Loggeable, LogSource, ThreadPoolMBean
public class ThreadPool
- extends java.lang.ThreadGroup
- implements LogSource, Loggeable, Configurable, ThreadPoolMBean
Implements a ThreadPool with the ability to run simple Runnable
tasks as well as Jobs (supervised Runnable tasks)
- Since:
- 1.1
- Author:
- apr@cs.com.uy
|
Constructor Summary |
ThreadPool()
Default constructor for ThreadPool |
ThreadPool(int poolSize,
int maxPoolSize)
|
ThreadPool(int poolSize,
int maxPoolSize,
java.lang.String name)
|
| Methods inherited from class java.lang.ThreadGroup |
activeCount, activeGroupCount, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, parentOf, resume, setDaemon, setMaxPriority, stop, suspend, toString, uncaughtException |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
DEFAULT_MAX_THREADS
public static final int DEFAULT_MAX_THREADS
- See Also:
- Constant Field Values
ThreadPool
public ThreadPool(int poolSize,
int maxPoolSize)
- Parameters:
poolSize - starting pool sizemaxPoolSize - maximum number of threads on this pool
ThreadPool
public ThreadPool(int poolSize,
int maxPoolSize,
java.lang.String name)
- Parameters:
name - pool namepoolSize - starting pool sizemaxPoolSize - maximum number of threads on this pool
ThreadPool
public ThreadPool()
- Default constructor for ThreadPool
close
public void close()
execute
public void execute(java.lang.Runnable action)
throws BlockingQueue.Closed
- Throws:
BlockingQueue.Closed
dump
public void dump(java.io.PrintStream p,
java.lang.String indent)
- Specified by:
dump in interface Loggeable
getJobCount
public int getJobCount()
- Specified by:
getJobCount in interface ThreadPoolMBean
- Returns:
- number of jobs processed by this pool
getPoolSize
public int getPoolSize()
- Specified by:
getPoolSize in interface ThreadPoolMBean
- Returns:
- number of active threads
getMaxPoolSize
public int getMaxPoolSize()
- Specified by:
getMaxPoolSize in interface ThreadPoolMBean
- Returns:
- max number of active threads allowed
getIdleCount
public int getIdleCount()
- Specified by:
getIdleCount in interface ThreadPoolMBean
- Returns:
- number of idle threads
getAvailableCount
public int getAvailableCount()
- Returns:
- number of available threads
getPendingCount
public int getPendingCount()
- Specified by:
getPendingCount in interface ThreadPoolMBean
- Returns:
- number of Pending jobs
supervise
public void supervise()
setLogger
public void setLogger(Logger logger,
java.lang.String realm)
- Specified by:
setLogger in interface LogSource
getRealm
public java.lang.String getRealm()
- Specified by:
getRealm in interface LogSource
getLogger
public Logger getLogger()
- Specified by:
getLogger in interface LogSource
setConfiguration
public void setConfiguration(Configuration cfg)
throws ConfigurationException
- Specified by:
setConfiguration in interface Configurable
- Parameters:
cfg - Configuration object
- Throws:
ConfigurationException
getThreadPool
public static ThreadPool getThreadPool(java.lang.String name)
throws NameRegistrar.NotFoundException
- Retrieves a thread pool from NameRegistrar given its name, unique identifier.
- Parameters:
name - Name of the thread pool to retrieve, must be the same as the name property of the thread-pool tag in the QSP config file
- Returns:
- returns the retrieved instance of thread pool
- Throws:
NameRegistrar.NotFoundException - thrown when there is not a thread-pool registered under this name.