Class MThread

  • All Implemented Interfaces:
    ILog, MNlsProvider, Nls, Runnable
    Direct Known Subclasses:
    MThreadDaemon

    public class MThread
    extends MObject
    implements Runnable
    Author:
    hummel To change the template for this generated type comment go to Window>Preferences>Java>Code Generation>Code and Comments
    • Constructor Detail

      • MThread

        public MThread()
      • MThread

        public MThread​(String _name)
      • MThread

        public MThread​(Runnable _task)
    • Method Detail

      • getTask

        protected Runnable getTask()
      • run

        public void run()
        Specified by:
        run in interface Runnable
      • initThread

        protected void initThread​(Thread thread)
      • setName

        public void setName​(String _name)
      • getName

        public String getName()
      • setPriority

        public void setPriority​(int _p)
      • getPriority

        public int getPriority()
      • stop

        public void stop()
      • interupt

        public void interupt()
      • sleep

        public static void sleep​(long _millisec)
        Sleeps _millisec milliseconds. On Error (e.g. a break), it prints a stacktrace dump.
        Parameters:
        _millisec -
      • taskError

        protected void taskError​(Throwable t)
      • asynchron

        public static void asynchron​(Runnable task)
      • getWithTimeout

        public static <T> T getWithTimeout​(ValueProvider<T> provider,
                                           long timeout,
                                           boolean nullAllowed)
        Try every 200ms to get the value. If the provider throws an error or return null the try will be repeated. If the time out is reached a TimeoutRuntimeException will be thrown.
        Parameters:
        provider -
        timeout -
        nullAllowed -
        Returns:
        The requested value
      • getAsynchronWithTimeout

        public static <T> T getAsynchronWithTimeout​(ValueProvider<T> provider,
                                                    long timeout,
                                                    boolean nullAllowed)
        Like getWithTimeout but executed in a separate task, this means unblocking.
        Parameters:
        provider -
        timeout -
        nullAllowed -
        Returns:
        The requested value
      • getAsynchronWithTimeout

        public static <T> T getAsynchronWithTimeout​(ValueProvider<T> provider,
                                                    long timeout)
                                             throws Exception
        Calls the provider once and will return the result. The provider is called in a separate thread to
        Parameters:
        provider -
        timeout -
        Returns:
        The requested value
        Throws:
        Exception
      • waitFor

        public static void waitFor​(Checker checker,
                                   long timeout)
        Wait for the checker to return true or throw an TimeoutRuntimeException on timeout. A exception in the checker will be ignored.
        Parameters:
        checker -
        timeout -
      • waitForWithException

        public static void waitForWithException​(Checker checker,
                                                long timeout)
                                         throws Exception
        Wait for the checker to return true or throw an TimeoutRuntimeException on timeout.
        Parameters:
        checker -
        timeout -
        Throws:
        Exception - Thrown if checker throws an exception
      • getThread

        public Thread getThread()