org.apache.logging.log4j.core.util
Class CachedClock

java.lang.Object
  extended by org.apache.logging.log4j.core.util.CachedClock
All Implemented Interfaces:
Clock

public final class CachedClock
extends Object
implements 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().


Method Summary
 long currentTimeMillis()
          Returns the value of a private long field that is updated by a background thread once every millisecond.
static CachedClock instance()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static CachedClock 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 interface Clock
Returns:
the cached time


Copyright © 1999-2014 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.