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.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Flag if the thread was borrowed.protected long
Departure time of the thread from the pool.protected int
The thread number assigned to the thread.protected MonitoredThreadPoolExecutor
Thread 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 void
borrow()
Notify the pool that the thread is borrowed and return the return to the pool is expected to be delayed.long
Gets the time the thread departed from the pool.int
Gets the thread number.boolean
Returns if the thread is currently blocked.boolean
Returns if the thread is currently borrowed.void
setDeparture
(long departure) Sets the time the thread departed from the pool.void
setNumber
(int num) Sets the thread number.static final void
Try 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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, 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.
-