Package org.apache.hadoop.util
Class Timer
java.lang.Object
org.apache.hadoop.util.Timer
Utility methods for getting the time and computing intervals.
It has the same behavior as {
Time}, with the exception that its
functions can be overridden for dependency injection purposes.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongCurrent time from some arbitrary time base in the past, counting in milliseconds, and not affected by settimeofday or similar system clock changes.longSame asmonotonicNow()but returns its result in nanoseconds.longnow()Current system time.
-
Constructor Details
-
Timer
public Timer()
-
-
Method Details
-
now
public long now()Current system time. Do not use this to calculate a duration or interval to sleep, because it will be broken by settimeofday. Instead, use monotonicNow.- Returns:
- current time in msec.
-
monotonicNow
public long monotonicNow()Current time from some arbitrary time base in the past, counting in milliseconds, and not affected by settimeofday or similar system clock changes. This is appropriate to use when computing how much longer to wait for an interval to expire.- Returns:
- a monotonic clock that counts in milliseconds.
-
monotonicNowNanos
public long monotonicNowNanos()Same asmonotonicNow()but returns its result in nanoseconds. Note that this is subject to the same resolution constraints asSystem.nanoTime().- Returns:
- a monotonic clock that counts in nanoseconds.
-