Package jadex.commons.concurrent
Class MonitoredThreadPoolExecutor
- java.lang.Object
- 
- java.util.concurrent.AbstractExecutorService
- 
- java.util.concurrent.ThreadPoolExecutor
- 
- jadex.commons.concurrent.MonitoredThreadPoolExecutor
 
 
 
- 
- All Implemented Interfaces:
- java.util.concurrent.Executor,- java.util.concurrent.ExecutorService
 
 public class MonitoredThreadPoolExecutor extends java.util.concurrent.ThreadPoolExecutorThread pool executor based on the Java 5 ThreadPoolExecutor class. Uses a monitoring thread to monitor pool thread behavior to adjust pool size.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutorjava.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected static booleanAGGRESSIVEIf true, be more aggressive when creating threads.protected static intBASE_TCNTStarting number of threads.protected static booleanDEBUGPrint debug messagesprotected java.util.concurrent.atomic.AtomicIntegeridleNumber of idle threads in the pool.protected static longLOSS_THRESHOLDThreshold after which a _blocking_ thread is considered stolen.protected static longLOSS_THRESHOLD_BUSYThreshold after which a _non-blocking_ thread is considered stolen.protected static longMONIT_CYCLEMin.protected static intMONIT_THRESHOLDThreshold for activating monitoring.protected booleanmonitoringFlag for monitoring thread activity.protected java.util.concurrent.SemaphoremonitoringlockThe lock for the monitoring thread.protected java.lang.ThreadmonitthreadThe monitoring thread.protected MonitoredThread[]threadsThe threads in the pool.
 - 
Constructor SummaryConstructors Constructor Description MonitoredThreadPoolExecutor()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidborrow(MonitoredThread thread)Borrows the thread.protected voidborrowNoUnpark(MonitoredThread thread)Borrows the thread without unparking.protected static MonitoredThreadcurrentThread()Gets the current MonitoredThread, for convenience.voidexecute(java.lang.Runnable command)protected static voidreleaseLock(java.util.concurrent.Semaphore lock)Releases the semaphore, includes null check.- 
Methods inherited from class java.util.concurrent.ThreadPoolExecutorafterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated, toString
 
- 
 
- 
- 
- 
Field Detail- 
DEBUGprotected static final boolean DEBUG Print debug messages- See Also:
- Constant Field Values
 
 - 
AGGRESSIVEprotected static final boolean AGGRESSIVE If true, be more aggressive when creating threads.- See Also:
- Constant Field Values
 
 - 
MONIT_THRESHOLDprotected static final int MONIT_THRESHOLD Threshold for activating monitoring.
 - 
BASE_TCNTprotected static final int BASE_TCNT Starting number of threads.
 - 
MONIT_CYCLEprotected static final long MONIT_CYCLE Min. wait time between monitoring cycles.- See Also:
- Constant Field Values
 
 - 
LOSS_THRESHOLDprotected static final long LOSS_THRESHOLD Threshold after which a _blocking_ thread is considered stolen.- See Also:
- Constant Field Values
 
 - 
LOSS_THRESHOLD_BUSYprotected static final long LOSS_THRESHOLD_BUSY Threshold after which a _non-blocking_ thread is considered stolen.- See Also:
- Constant Field Values
 
 - 
idleprotected java.util.concurrent.atomic.AtomicInteger idle Number of idle threads in the pool.
 - 
threadsprotected volatile MonitoredThread[] threads The threads in the pool.
 - 
monitoringlockprotected volatile java.util.concurrent.Semaphore monitoringlock The lock for the monitoring thread.
 - 
monitthreadprotected java.lang.Thread monitthread The monitoring thread.
 - 
monitoringprotected boolean monitoring Flag for monitoring thread activity.
 
- 
 - 
Method Detail- 
executepublic void execute(java.lang.Runnable command) - Specified by:
- executein interface- java.util.concurrent.Executor
- Overrides:
- executein class- java.util.concurrent.ThreadPoolExecutor
 
 - 
borrowprotected void borrow(MonitoredThread thread) Borrows the thread.- Parameters:
- thread- Thre thread being borrowed.
 
 - 
borrowNoUnparkprotected void borrowNoUnpark(MonitoredThread thread) Borrows the thread without unparking.- Parameters:
- thread- Thre thread being borrowed.
 
 - 
releaseLockprotected static final void releaseLock(java.util.concurrent.Semaphore lock) Releases the semaphore, includes null check.- Parameters:
- lock- The lock.
 
 - 
currentThreadprotected static final MonitoredThread currentThread() Gets the current MonitoredThread, for convenience.- Returns:
- Current MonitoredThread.
 
 
- 
 
-