Class DriftAwareThread

  • All Implemented Interfaces:
    Runnable

    public class DriftAwareThread
    extends Thread
    A thread that can run a ITimerTask accounting for drifting time.
    • Constructor Detail

      • DriftAwareThread

        public DriftAwareThread​(String name,
                                ITimerTask runnable,
                                long interval)
        Create a new thread.
        Parameters:
        name - the name for the thread
        runnable - the ITimerTask to execute
        interval - the interval in ms between each execution
    • Method Detail

      • start

        public void start​(long delay)
        Start the thread using the provided delay.
        Parameters:
        delay - a delay in ms
      • run

        public void run()
        Specified by:
        run in interface Runnable
        Overrides:
        run in class Thread
      • whatIsNextExecutionTime

        protected long whatIsNextExecutionTime​(long executionTime,
                                               long now)