Class CachedClock
java.lang.Object
org.apache.logging.log4j.core.util.CachedClock
- All Implemented Interfaces:
Clock
Implementation of the
Clock
interface that tracks the time in a
private long field that is updated by a background thread once every
millisecond. Timers on most platforms do not have millisecond granularity, so
the returned value may "jump" every 10 or 16 milliseconds. To reduce this
problem, this class also updates the internal time value every 1024 calls to
currentTimeMillis()
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate short
private static CachedClock
private static final Object
private long
private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
Returns the value of a private long field that is updated by a background thread once every millisecond.static CachedClock
instance()
-
Field Details
-
UPDATE_THRESHOLD
private static final int UPDATE_THRESHOLD- See Also:
-
instance
-
INSTANCE_LOCK
-
millis
private volatile long millis -
count
private short count
-
-
Constructor Details
-
CachedClock
private CachedClock()
-
-
Method Details
-
instance
-
currentTimeMillis
public long currentTimeMillis()Returns the value of a private long field that is updated by a background thread once every millisecond. Timers on most platforms do not have millisecond granularity, the returned value may "jump" every 10 or 16 milliseconds. To reduce this problem, this method also updates the internal time value every 1024 calls.- Specified by:
currentTimeMillis
in interfaceClock
- Returns:
- the cached time
-