Package net.targetr.wtm3.util
Class Clock
java.lang.Object
net.targetr.wtm3.util.Clock
Abstraction for the system clock.
- Author:
- Dr Michael Gardiner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longmillis()Returns the current time in milliseconds since unix epoch.static longrealtime()Returns monotonic time in milliseconds from an arbitrary origin.static voidsleep(int millis) Pauses the current thread for the specified number of milliseconds.
-
Constructor Details
-
Clock
public Clock()Default constructor for Clock.
-
-
Method Details
-
millis
public static long millis()Returns the current time in milliseconds since unix epoch.- Returns:
- Time in milliseconds since unix epoch.
-
realtime
public static long realtime()Returns monotonic time in milliseconds from an arbitrary origin. Use differences within this JVM for elapsed time; this is not a wall-clock timestamp.- Returns:
- a value in milliseconds for measuring time differences
-
sleep
public static void sleep(int millis) Pauses the current thread for the specified number of milliseconds.- Parameters:
millis- The number of milliseconds to sleep.- Throws:
RuntimeException- If the thread is interrupted while sleeping.
-