Last active
April 28, 2021 08:44
-
-
Save soudmaijer/e073b3a282b76a91aec8d7281fa98d67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.GlobalScope | |
import kotlinx.coroutines.async | |
import kotlinx.coroutines.delay | |
import java.lang.Thread.sleep | |
fun main() { | |
val a = GlobalScope.async { throw RuntimeException() } | |
val b = GlobalScope.async { delay(2000).also { println("I leaked!") } } // Will not be printed! | |
println(a) | |
println(b) | |
sleep(2500) | |
println(a) | |
println(b) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment