org.jpos.util
Class ThreadPool
java.lang.Object
java.lang.ThreadGroup
org.jpos.util.ThreadPool
- All Implemented Interfaces:
- Thread.UncaughtExceptionHandler, Configurable, Loggeable, LogSource, ThreadPoolMBean
public class ThreadPool
- extends 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
| 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 |
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,
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(Runnable action)
throws BlockingQueue.Closed
- Throws:
BlockingQueue.Closed
dump
public void dump(PrintStream p,
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 running threads
getMaxPoolSize
public int getMaxPoolSize()
- Specified by:
getMaxPoolSize in interface ThreadPoolMBean
- Returns:
- max number of active threads allowed
getActiveCount
public int getActiveCount()
- Returns:
- number of active threads
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,
String realm)
- Specified by:
setLogger in interface LogSource
getRealm
public 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(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.
Copyright © 1998-2012 jPOS.org. All Rights Reserved.