marcinmoskala
10/12/2018, 4:37 PMfun main(args: Array<String>) = runBlocking<Unit> {
val job = launch {
var nextPrintTime = System.currentTimeMillis() + 500
while (isActive) {
if(System.currentTimeMillis() > nextPrintTime) {
println("World!")
nextPrintTime += 1000
}
}
}
println("Hello,")
delay(2000)
job.cancelAndJoin()
println("World")
}
It should stop correctly after 2 seconds because if Job was cancelled, isActive should return false. But in my machine it works infinitively. On EREPL it throws Program was terminated after 10s.⌛️