public class Stopwatch extends Object
| Constructor and Description |
|---|
Stopwatch()
Constructor initializes a new Stopwatch.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getEndTime()
Method returns the timestamp of the last Stopwatch stop.
|
long |
getStartTime()
Method returns the timestamp of the Stopwatch start.
|
long |
getTime()
This method returns the time interval between the start- and end timestamps.
|
boolean |
isRunning()
Method checks if the Stopwatch was started after reset.
|
void |
reset()
This method resets the Stopwatch by clearing the internally stored start and end timestamps.
|
void |
restart()
This method restarts the Stopwatch.
|
void |
start()
This method starts the Stopwatch by setting the start timestamp.
|
long |
stop()
This method stops the Stopwatch and returns the time result.
|
void |
waitForStart()
Method blocks until the Stopwatch start.
|
void |
waitForStart(long timeout)
Method blocks until the Stopwatch start or the given timeout expired.
|
void |
waitForStop()
Method blocks until the Stopwatch stop.
|
void |
waitForStop(long timeout)
Method blocks until the Stopwatch stop or the given timeout expired.
|
public final void reset()
public void start()
public void restart()
public long getTime()
throws NotAvailableException
NotAvailableException - This exception will thrown in case the timer was never started.public boolean isRunning()
public long stop()
throws CouldNotPerformException
CouldNotPerformException - is thrown in case the Stopwatch was never started.public long getStartTime()
throws NotAvailableException
NotAvailableException - is thrown in case the Stopwatch was never started.public long getEndTime()
throws NotAvailableException
NotAvailableException - is thrown in case the Stopwatch was never started.public void waitForStart(long timeout)
throws InterruptedException
timeout - max time to wait.InterruptedException - is thrown in case the current thread was externally interrupted.public void waitForStart()
throws InterruptedException
InterruptedException - is thrown in case the current thread was externally interrupted.public void waitForStop(long timeout)
throws InterruptedException
timeout - max time to wait.InterruptedException - is thrown in case the current thread was externally interrupted.public void waitForStop()
throws InterruptedException
InterruptedException - is thrown in case the current thread was externally interrupted.Copyright © 2015–2017 openbase.org. All rights reserved.