Class WaitTimeout<a>

  • Type Parameters:
    a - the returned object data type
    All Implemented Interfaces:
    java.lang.Runnable
    Direct Known Subclasses:
    ThreadUtil.WaitTimeout

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

      Fields 
      Modifier and Type Field Description
      protected java.lang.String baseName  
    • Constructor Summary

      Constructors 
      Constructor Description
      WaitTimeout​(int millis)  
    • Field Detail

      • baseName

        protected java.lang.String baseName
    • Constructor Detail

      • WaitTimeout

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

      • 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 java.lang.String getBaseName()
        Returns:
        the baseName
      • setBaseName

        public void setBaseName​(java.lang.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 java.lang.Runnable
        See Also:
        Runnable.run()
      • 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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()