public abstract class BlockingTimerTask extends TimerTask
runImpl()
rather than run()
.
The await()
method will block in the calling Thread until the timer is run (so after the timer has
elapsed). However if you don't call the await()
method, the BlockingTimerTask will work just like a
TimerTask
.
You must be aware that if you have a periodic timer, the await()
method will block for each iteration
of the timer loop, which might not be what you want.Constructor and Description |
---|
BlockingTimerTask() |
Modifier and Type | Method and Description |
---|---|
void |
await()
Await for the timer to elaapse.
|
boolean |
cancel() |
void |
run()
The action to be performed by this timer task.
|
abstract void |
runImpl()
The code to be run after the timer has elapsed.
|
scheduledExecutionTime
public abstract void runImpl()
public final void run()
public void await() throws InterruptedException
InterruptedException