October 2019
Intermediate to advanced
434 pages
11h 54m
English
Coroutines in Kotlin include the notion of suspending functions. Suspending functions are denoted by adding the suspend modifier to a function definition. There are two key things to remember regarding suspending functions:
If we return to our working example, we can see an example of the suspend function, delay():
fun main() { GlobalScope.launch { delay(500) // simulate network request println("Coroutines") } println("Hello") Thread.sleep(1000)}
delay() is a suspending function that will suspend the current coroutine for a specified amount of time. Suspending functions is the primary mechanism ...
Read now
Unlock full access