Every timer also has an associated thread (such as JavaFX application
thread or a single-thread executor's thread). Timer may only be accessed
from its associated thread. Timer's action is executed on its associated
thread, too. This design allows to implement guarantees provided by
stop().
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | stop()
If the associated action has been scheduled for execution but not yet executed, this method prevents it from being executed at all. |
| restart | back to summary |
|---|---|
| public void restart() Schedules the associated action to be executed after the associated delay. If the action is already scheduled but hasn't been executed yet, the timeout is reset, so that the action won't be executed before the full delay from now. | |
| stop | back to summary |
|---|---|
| public void stop() If the associated action has been scheduled for execution but not yet
executed, this method prevents it from being executed at all. This is
also true in case the timer's timeout has already expired, but the
associated action hasn't had a chance to be executed on the associated
thread. Note that this is a stronger guarantee than the one given by
In contrast, using the FxTimer, the action is guaranteed not to
be executed after stop():
| |