# Scheduling tasks with Eclipse Vert.x

cescoffier
17K views

## One-shot Timers

The first type of timer is used to create a delayed action. An one-shot timer calls a handler after a certain delay, expressed in milliseconds. A Handler being a method invoked by Vert.x when something interesting happens - here the execution trigger.

One-shot timer

The return value is a unique timer id which can later be used to cancel the timer. The handler is also passed the timer id.

Passing milliseconds can be inconvenient for long durations. Fortunately, you can use TimeUnit:

Using TimeUnit

To give another example, you can compute the number of milliseconds in a hour using:

TimeUnit.HOURS.toMillis(1)

Open Source Your Knowledge: become a Contributor and help others learn.