Class SystemNanoClock

  • All Implemented Interfaces:
    NanoClock

    public class SystemNanoClock
    extends java.lang.Object
    implements NanoClock
    A NanoClock the delegates to System.nanoTime().

    Instances are threadsafe.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static SystemNanoClock INSTANCE
      As there is no instance state then this object can be used to save on allocation.
    • Constructor Summary

      Constructors 
      Constructor Description
      SystemNanoClock()
      Create a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long nanoTime()
      The number of ticks in nanoseconds the clock has advanced since starting.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INSTANCE

        public static final SystemNanoClock INSTANCE
        As there is no instance state then this object can be used to save on allocation.
    • Constructor Detail

      • SystemNanoClock

        public SystemNanoClock()
        Create a new instance.
    • Method Detail

      • nanoTime

        public long nanoTime()
        The number of ticks in nanoseconds the clock has advanced since starting.

        This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary origin time (perhaps in the future, so values may be negative). The same origin is used by all invocations of this method in an instance of a Java virtual machine; other virtual machine instances are likely to use a different origin.

        Specified by:
        nanoTime in interface NanoClock
        Returns:
        number of ticks in nanoseconds the clock has advanced since starting.
        See Also:
        System.nanoTime()