I've been trying to find an explanation on why this works in kotlin:
(1..100).map {
launch {
System.out.println("Hello from on ${Thread.currentThread().name}")
delay(100)
}
}.forEach { it.join() }
In java this would:
- start thread 1
- join thread 1 - and block here, never starting more than 1 thread.
In kotlin this process on multiple threads in parallel.
Why does this work?