Read the code carefully before you run it.
import kotlinx.coroutines.*
fun main() = runBlocking {
launch(Dispatchers.Default) { println("A") }
launch(Dispatchers.Default) { println("B") }
}
Does this program guarantee that it prints A first and then B on every run?
A small order service should start its own coroutine for every incoming order, reporting which thread handles it. Complete the forEach loop: start a coroutine with launch(Dispatchers.Default) for each order, printing "$order runs on ${Thread.currentThread().name}".
Before you get a hint: what have you tried, and where exactly are you stuck?
1. How does the lesson distinguish parallelism and concurrency?
2. A program with two coroutines runs on a machine with only one CPU core. Is that possible?
3. According to this lesson, what was the motivation for programming in parallel or concurrently at all?