```fun main() = runBlocking { repeat(50) { launch(<http://Dispatchers.IO|Dispatchers.IO>...
j
Copy code
fun main() = runBlocking {
    repeat(50) {
        launch(<http://Dispatchers.IO|Dispatchers.IO>) {
            delay(5000L * it)
            println("Done $it")
        }
    }
}
Having some code like this. Is it possible to leak coroutines, if I were to just send the kill signal to this process?
👀 1
s
If you kill the process all coroutines must be gone by definition ?
☝️ 1
z
You couldn't even leak threads like this, and coroutines are an entirely userspace construct.
j
Great, thanks. Just wanted to be 100% sure 😛 Cause when creating a test like this:
Copy code
@Test
fun threads() = runBlockingTest {
    (1..50).map {
        launch(<http://Dispatchers.IO|Dispatchers.IO>) {
            delay(5000L * it)
            println("Done $it")
        }
    }.joinAll()
}
The test will fail, so just wanted to be sure if that wasn't leaked anywhere. To ask a new question, what's the reason for that specific test failing?
u
what does it say?
j
java.lang.IllegalStateException: This job has not completed yet
t
This is a known bug of
runBlockingTest
, it seems that using another dispatcher conflicts with the auto-advancing time feature. You may reproduce the same problem with
withContext
👍 1