Class Clock.Virtual

  • Enclosing class:
    Clock

    public static class Clock.Virtual
    extends Clock
    A virtual clock that has no connection to the actual system time. Instead the clock maintains an internal counter that's incremented atomically whenever the current time is requested. This guarantees that the reported time signal is always strictly increasing.
    • Constructor Detail

      • Virtual

        public Virtual()
    • Method Detail

      • getTime

        public long getTime()
        Description copied from class: Clock
        Returns the current time in milliseconds since the epoch.
        Specified by:
        getTime in class Clock
        Returns:
        current time in milliseconds since the epoch
        See Also:
        System.currentTimeMillis(), Clock.millis()
      • waitUntil

        public void waitUntil​(long timestamp)
        Description copied from class: Clock
        Waits until the given point in time is reached. The current thread is suspended until the Clock.getTimeIncreasing() method returns a time that's equal or greater than the given point in time.
        Overrides:
        waitUntil in class Clock
        Parameters:
        timestamp - time in milliseconds since epoch
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object