I have a problem with this code: ``` fun main(args...
# coroutines
m
I have a problem with this code:
Copy code
fun 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.⌛️