Runs a block of code in this ExecutionContext
.
Runs a block of code in this ExecutionContext
.
Schedules the given action
for immediate execution.
Schedules the given action
for immediate execution.
a Cancelable that can be used to cancel the task in case it hasn't been executed yet.
Returns the current value of the running virtual machine's high-resolution time source, in nanoseconds.
Returns the current value of the running virtual machine's high-resolution time source, in nanoseconds.
When wanting to measure how long it took for the execution of a callback to
happen, do not use System.nanoTime
directly, prefer this method instead,
because then it can be mocked for testing purposes (see for example
TestScheduler)
Reports that an asynchronous computation failed.
Reports that an asynchronous computation failed.
Schedules a periodic task that becomes enabled first after the given initial delay, and subsequently with the given period.
Schedules a periodic task that becomes enabled first after the given
initial delay, and subsequently with the given period. Executions will
commence after initialDelay
then initialDelay + period
, then
initialDelay + 2 * period
and so on.
If any execution of the task encounters an exception, subsequent executions are suppressed. Otherwise, the task will only terminate via cancellation or termination of the scheduler. If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.
For example the following schedules a message to be printed to standard output approximately every 10 seconds with an initial delay of 5 seconds:
val task = scheduler.scheduleAtFixedRate(5.seconds, 10.seconds) { println("Hello, world!") } // later if you change your mind ... task.cancel()
is the time to wait until the first execution happens
is the time to wait between 2 subsequent executions of the task
is the callback to be executed
a cancelable that can be used to cancel the execution of this repeated task at any time.
Schedules a periodic task that becomes enabled first after the given initial delay, and subsequently with the given period.
Schedules a periodic task that becomes enabled first after the given
initial delay, and subsequently with the given period. Executions will
commence after initialDelay
then initialDelay + period
, then
initialDelay + 2 * period
and so on.
If any execution of the task encounters an exception, subsequent executions are suppressed. Otherwise, the task will only terminate via cancellation or termination of the scheduler. If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.
For example the following schedules a message to be printed to standard output approximately every 10 seconds with an initial delay of 5 seconds:
val task = scheduler.scheduleAtFixedRate(5.seconds, 10.seconds , new Runnable { def run() = println("Hello, world!") }) // later if you change your mind ... task.cancel()
is the time to wait until the first execution happens
is the time to wait between 2 subsequent executions of the task
is the callback to be executed
a cancelable that can be used to cancel the execution of this repeated task at any time.
Schedules a task to run in the future, after initialDelay
.
Schedules a task to run in the future, after initialDelay
.
For example the following schedules a message to be printed to standard output after 5 minutes:
val task = scheduler.scheduleOnce(5.minutes, new Runnable { def run() = println("Hello, world!") }) // later if you change your mind ... task.cancel()
is the time to wait until the execution happens
is the callback to be executed
a Cancelable
that can be used to cancel the created task
before execution.
Schedules a task to run in the future, after initialDelay
.
Schedules a task to run in the future, after initialDelay
.
For example the following schedules a message to be printed to standard output after 5 minutes:
val task = scheduler.scheduleOnce(5.minutes) { println("Hello, world!") } // later if you change your mind ... task.cancel()
is the time to wait until the execution happens
is the callback to be executed
a Cancelable
that can be used to cancel the created task
before execution.
Schedules for execution a periodic task that is first executed after the given initial delay and subsequently with the given delay between the termination of one execution and the commencement of the next.
Schedules for execution a periodic task that is first executed after the given initial delay and subsequently with the given delay between the termination of one execution and the commencement of the next.
For example the following schedules a message to be printed to standard output every 10 seconds with an initial delay of 5 seconds:
val task = s.scheduleWithFixedDelay(5.seconds, 10.seconds) { println("Hello, world!") } // later if you change your mind ... task.cancel()
is the time to wait until the first execution happens
is the time to wait between 2 subsequent executions of the task
is the callback to be executed
a cancelable that can be used to cancel the execution of this repeated task at any time.
Schedules for execution a periodic task that is first executed after the given initial delay and subsequently with the given delay between the termination of one execution and the commencement of the next.
Schedules for execution a periodic task that is first executed after the given initial delay and subsequently with the given delay between the termination of one execution and the commencement of the next.
For example the following schedules a message to be printed to standard output every 10 seconds with an initial delay of 5 seconds:
val task = s.scheduleWithFixedDelay(5.seconds, 10.seconds, new Runnable { def run() = println("Hello, world!") }) // later if you change your mind ... task.cancel()
is the time to wait until the first execution happens
is the time to wait between 2 subsequent executions of the task
is the callback to be executed
a cancelable that can be used to cancel the execution of this repeated task at any time.