July 2018
Intermediate to advanced
266 pages
7h 11m
English
Suspending functions are suspending computations in the shape of a function. A suspending function can be easily identified because of the modifier suspend. For example:
suspend fun greetAfter(name: String, delayMillis: Long) { delay(delayMillis) println("Hello, $name")}
In the previous example, the execution of greetAfter() will be suspended when delay() is called – delay() is a suspending function itself, suspending the execution for a give duration. Once delay() has been completed, greetAfter() will resume its execution normally. And while greetAfter() is suspended, the thread of execution may be used to do other computations.
Read now
Unlock full access