Last active
April 28, 2021 08:41
-
-
Save soudmaijer/b1e547cd4b026c5bf493f5f48d8fd033 to your computer and use it in GitHub Desktop.
This file contains 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