Skip to content

Instantly share code, notes, and snippets.

@soudmaijer
Last active April 28, 2021 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soudmaijer/b1e547cd4b026c5bf493f5f48d8fd033 to your computer and use it in GitHub Desktop.
Save soudmaijer/b1e547cd4b026c5bf493f5f48d8fd033 to your computer and use it in GitHub Desktop.
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