Class WaitTimeout<a>

java.lang.Object
org.cip4.jdflib.util.thread.WaitTimeout<a>
Type Parameters:
a - the returned object data type
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ThreadUtil.WaitTimeout

public abstract class WaitTimeout<a> extends Object implements Runnable
abstract class to run uninteruptable stuff in an interruptable thread
  • Field Details

    • baseName

      protected String baseName
  • Constructor Details

    • WaitTimeout

      public WaitTimeout(int millis)
      Parameters:
      millis - wait timeout in milliseconds
  • Method Details

    • handle

      protected abstract a handle()
      this is the handle routine that may take longer
      it should return the expected object when completed
      Returns:
      the object that this whole class is about
    • setup

      protected void setup()
      called prior to starting thread, overwrite to initialize in the constructor
    • getBaseName

      public String getBaseName()
      Returns:
      the baseName
    • setBaseName

      public void setBaseName(String baseName)
      Parameters:
      baseName - the baseName to set
    • getWaitMillis

      public int getWaitMillis()
      Returns:
      the waitMillis
    • start

      public final void start()
      start the thread
    • run

      public final void run()
      Specified by:
      run in interface Runnable
      See Also:
    • getWaitedObject

      public final a getWaitedObject()
      Returns:
      the object that you waited for, null if the timeout is reached
    • peekWaitedObject

      public final a peekWaitedObject()
      Returns:
      the object that you waited for, if it has been calculated
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also: