Class CoarseCachedClock
- java.lang.Object
-
- org.apache.logging.log4j.core.util.CoarseCachedClock
-
-
Field Summary
Fields Modifier and Type Field Description private static CoarseCachedClock
instance
private static java.lang.Object
INSTANCE_LOCK
private long
millis
private java.lang.Thread
updater
-
Constructor Summary
Constructors Modifier Constructor Description private
CoarseCachedClock()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
currentTimeMillis()
Returns the value of a private long field that is updated by a background thread once every millisecond.static CoarseCachedClock
instance()
Returns the singleton instance.
-
-
-
Field Detail
-
instance
private static volatile CoarseCachedClock instance
-
INSTANCE_LOCK
private static final java.lang.Object INSTANCE_LOCK
-
millis
private volatile long millis
-
updater
private final java.lang.Thread updater
-
-
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 interfaceClock
- Returns:
- the cached time
-
-