Class MonitoredThread

java.lang.Object
java.lang.Thread
jadex.concurrent.MonitoredThread
All Implemented Interfaces:
Runnable

public class MonitoredThread extends Thread
Thread class used by MonitoredThreadPoolExecutor, contains additional state about the thread to monitor thread behavior.
  • Field Details

    • origin

      protected MonitoredThreadPoolExecutor origin
      Thread pool executor that created the thread.
    • number

      protected int number
      The thread number assigned to the thread.
    • departure

      protected volatile long departure
      Departure time of the thread from the pool.
    • borrowed

      protected volatile boolean borrowed
      Flag if the thread was borrowed.
  • Constructor Details

    • MonitoredThread

      public MonitoredThread(Runnable r, MonitoredThreadPoolExecutor origin)
      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.