JOSEPH FISHER
02/23/2022, 10:02 PMfun doLaunchOperation() {
println("START: doLaunchOperation()")
var i = 0;
val launchJob = GlobalScope.launch {
println("START: launch")
while (i<100){
println(i)
i++
}
println("END: launch")
}
while(launchJob.isActive){
println("launchJob.isActive")
}
println("done")
println("END: doLaunchOperation()")
}
ephemient
02/23/2022, 10:17 PMwhile
loop will never see any progress madeJOSEPH FISHER
02/23/2022, 10:31 PMephemient
02/23/2022, 10:34 PMrunBlocking { }
to bridge from async to sync. this function is absent in Kotlin/JS, due to the fact that it is impossible.suspend fun main() {
val job = GlobalScope.launch {
for (i in 1..100) {
println(i)
delay(100)
}
}
job.join()
}
works on all platforms, including JSJOSEPH FISHER
02/23/2022, 10:41 PMephemient
02/23/2022, 10:45 PMJOSEPH FISHER
02/23/2022, 11:35 PMephemient
02/23/2022, 11:48 PMJOSEPH FISHER
02/24/2022, 1:11 PMephemient
02/24/2022, 1:18 PMJOSEPH FISHER
02/24/2022, 1:21 PMephemient
02/24/2022, 1:26 PM