public class DefaultClock extends Clock implements java.lang.Runnable
The DefaultClock
is JBotSim default implementation of the Clock
.
Implementation remarks:
Thread
to perform the clock.Thread
will sleep for the specified time between each round.Thread
will keep the application alive until it is interrupted or the application is killed.Constructor and Description |
---|
DefaultClock(ClockManager manager) |
Modifier and Type | Method and Description |
---|---|
int |
getTimeUnit()
Returns the time unit of the clock, in milliseconds.
|
boolean |
isRunning()
Indicates whether the clock is currently running or paused.
|
void |
pause()
Pauses the clock.
|
void |
resume()
Resumes the clock if it was paused.
|
void |
run() |
void |
setTimeUnit(int delay)
Sets the time unit of the clock to the specified value in millisecond.
|
void |
start()
Starts the clock.
|
public DefaultClock(ClockManager manager)
public int getTimeUnit()
Clock
Returns the time unit of the clock, in milliseconds. The time unit is the duration of a round.
getTimeUnit
in class Clock
public void setTimeUnit(int delay)
Clock
setTimeUnit
in class Clock
delay
- The desired time unitpublic boolean isRunning()
Clock
public void start()
Clock
public void pause()
Clock
public void resume()
Clock
public void run()
run
in interface java.lang.Runnable