Package org.sm.smtools.util
Class Chrono
java.lang.Object
org.sm.smtools.util.Chrono
The
Chrono
class contains functionality for a simple chronometer.
With this class, a single chronometer with an accuracy of milliseconds can be used.
There is also a (static) method for suspending application execution for a certain amount of time.
Note that this class cannot be subclassed!
- Version:
- 01/04/2020
- Author:
- Sven Maerivoet
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
Queries this chronometer's elapsed time in milliseconds (excluding all stopped times).boolean
Returns whether or not the chronometer is currently running.void
reset()
Stops the chronometer and resets it's elapsed time to zero.void
start()
Starts/continues the chronometer.void
stop()
Stops the chronometer.static void
wait
(int ms) Suspends application execution for a certain amount of time.
-
Constructor Details
-
Chrono
public Chrono()Constructs a chronometer and resets it.
-
-
Method Details
-
reset
public void reset()Stops the chronometer and resets it's elapsed time to zero. -
start
public void start()Starts/continues the chronometer. -
stop
public void stop()Stops the chronometer. -
isRunning
public boolean isRunning()Returns whether or not the chronometer is currently running.- Returns:
- a
boolean
indicating whether or not the chronometer is currently running
-
getElapsedTime
public long getElapsedTime()Queries this chronometer's elapsed time in milliseconds (excluding all stopped times).- Returns:
- the chronometer's elapsed time in milliseconds
-
wait
public static void wait(int ms) Suspends application execution for a certain amount of time.Note that this is a static method and it should be called as:
Chrono.wait(...);
- Parameters:
ms
- the amount of time to wait, expressed in milliseconds
-