There are several fundamental concepts to understand when working with Kotlin coroutines. To highlight these, we can look at our example from the previous section:
fun main() {
GlobalScope.launch {
delay(500)
println("Coroutines")
}
println("Hello")
Thread.sleep(1000)
}
Within the preceding snippet, there are examples of three key concepts:
- Coroutine scopes
- Coroutine builders
- Suspending functions
Let's examine each of these in detail in the coming sections.