Class CoarseCachedClock

  • All Implemented Interfaces:
    Clock

    public final class CoarseCachedClock
    extends java.lang.Object
    implements Clock
    This Clock implementation is similar to CachedClock. It is slightly faster at the cost of some accuracy.
    • Field Detail

      • INSTANCE_LOCK

        private static final java.lang.Object INSTANCE_LOCK
      • millis

        private volatile long millis
      • updater

        private final java.lang.Thread updater
    • Constructor Detail

      • CoarseCachedClock

        private CoarseCachedClock()
    • Method Detail

      • instance

        public static CoarseCachedClock instance()
        Returns the singleton instance.
        Returns:
        the singleton instance
      • currentTimeMillis

        public long currentTimeMillis()
        Returns the value of a private long field that is updated by a background thread once every millisecond. Because timers on most platforms do not have millisecond granularity, the returned value may "jump" every 10 or 16 milliseconds.
        Specified by:
        currentTimeMillis in interface Clock
        Returns:
        the cached time