Package jadex.concurrent
Class MonitoredThread
java.lang.Object
java.lang.Thread
jadex.concurrent.MonitoredThread
- All Implemented Interfaces:
Runnable
Thread class used by MonitoredThreadPoolExecutor,
contains additional state about the thread to monitor thread behavior.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag if the thread was borrowed.protected longDeparture time of the thread from the pool.protected intThe thread number assigned to the thread.protected MonitoredThreadPoolExecutorThread pool executor that created the thread.Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionMonitoredThread(Runnable r, MonitoredThreadPoolExecutor origin) Creates the thread. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidborrow()Notify the pool that the thread is borrowed and return the return to the pool is expected to be delayed.longGets the time the thread departed from the pool.intGets the thread number.booleanReturns if the thread is currently blocked.booleanReturns 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 final voidTry to borrow the thread.Methods inherited from class java.lang.Thread
activeCount, 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 Details
-
origin
Thread pool executor that created the thread. -
number
protected int numberThe thread number assigned to the thread. -
departure
protected volatile long departureDeparture time of the thread from the pool. -
borrowed
protected volatile boolean borrowedFlag if the thread was borrowed.
-
-
Constructor Details
-
MonitoredThread
Creates the thread.- Parameters:
r- The runnable to execute.origin- The originating thread pool.
-
-
Method Details
-
getNumber
public int getNumber()Gets the thread number.- Returns:
- The thread number.
-
setNumber
public void setNumber(int num) Sets the thread number.- Parameters:
num- The thread number.
-
getDeparture
public long getDeparture()Gets the time the thread departed from the pool.- Returns:
- The time the thread departed from the pool.
-
setDeparture
public void setDeparture(long departure) Sets the time the thread departed from the pool.- Parameters:
departure- The time the thread departed from the pool.
-
borrow
protected void borrow()Notify the pool that the thread is borrowed and return the return to the pool is expected to be delayed. -
isBorrowed
public boolean isBorrowed()Returns if the thread is currently borrowed.- Returns:
- True, if borrowed.
-
isBlocked
public boolean isBlocked()Returns if the thread is currently blocked.- Returns:
- True, if blocked.
-
tryBorrow
public static final void tryBorrow()Try to borrow the thread. If thread is non-monitored, this does nothing.
-