Package jadex.commons.concurrent
Class MonitoredThread
- java.lang.Object
- 
- java.lang.Thread
- 
- jadex.commons.concurrent.MonitoredThread
 
 
- 
- All Implemented Interfaces:
- java.lang.Runnable
 
 public class MonitoredThread extends java.lang.ThreadThread class used by MonitoredThreadPoolExecutor, contains additional state about the thread to monitor thread behavior.
- 
- 
Field SummaryFields Modifier and Type Field Description protected booleanborrowedFlag if the thread was borrowed.protected longdepartureDeparture time of the thread from the pool.protected intnumberThe thread number assigned to the thread.protected MonitoredThreadPoolExecutororiginThread pool executor that created the thread.
 - 
Constructor SummaryConstructors Constructor Description MonitoredThread(java.lang.Runnable r, MonitoredThreadPoolExecutor origin)Creates the thread.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidborrow()Notify the pool that the thread is borrowed and return the return to the pool is expected to be delayed.longgetDeparture()Gets the time the thread departed from the pool.intgetNumber()Gets the thread number.booleanisBlocked()Returns if the thread is currently blocked.booleanisBorrowed()Returns if the thread is currently borrowed.voidsetDeparture(long departure)Sets the time the thread departed from the pool.voidsetNumber(int num)Sets the thread number.static voidtryBorrow()Try to borrow the thread.- 
Methods inherited from class java.lang.ThreadactiveCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
 
- 
 
- 
- 
- 
Field Detail- 
originprotected MonitoredThreadPoolExecutor origin Thread pool executor that created the thread.
 - 
numberprotected int number The thread number assigned to the thread.
 - 
departureprotected volatile long departure Departure time of the thread from the pool.
 - 
borrowedprotected volatile boolean borrowed Flag if the thread was borrowed.
 
- 
 - 
Constructor Detail- 
MonitoredThreadpublic MonitoredThread(java.lang.Runnable r, MonitoredThreadPoolExecutor origin)Creates the thread.- Parameters:
- r- The runnable to execute.
- origin- The originating thread pool.
 
 
- 
 - 
Method Detail- 
getNumberpublic int getNumber() Gets the thread number.- Returns:
- The thread number.
 
 - 
setNumberpublic void setNumber(int num) Sets the thread number.- Parameters:
- num- The thread number.
 
 - 
getDeparturepublic long getDeparture() Gets the time the thread departed from the pool.- Returns:
- The time the thread departed from the pool.
 
 - 
setDeparturepublic void setDeparture(long departure) Sets the time the thread departed from the pool.- Parameters:
- departure- The time the thread departed from the pool.
 
 - 
borrowprotected void borrow() Notify the pool that the thread is borrowed and return the return to the pool is expected to be delayed.
 - 
isBorrowedpublic boolean isBorrowed() Returns if the thread is currently borrowed.- Returns:
- True, if borrowed.
 
 - 
isBlockedpublic boolean isBlocked() Returns if the thread is currently blocked.- Returns:
- True, if blocked.
 
 - 
tryBorrowpublic static final void tryBorrow() Try to borrow the thread. If thread is non-monitored, this does nothing.
 
- 
 
-