Skip to content

Instantly share code, notes, and snippets.

@tdcolvin
Last active January 19, 2024 17:52
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 tdcolvin/c18ff7a435340db05f80f33419a2b364 to your computer and use it in GitHub Desktop.
Save tdcolvin/c18ff7a435340db05f80f33419a2b364 to your computer and use it in GitHub Desktop.
// !!!!! DON'T DO THIS !!!!!
suspend fun countToAHundredBillion_unsafe() {
var count = 0L
// This suspend fun won't be cancelled if the coroutine
// that's running it gets cancelled, because it doesn't
// ever yield.
while(count < 100_000_000_000) {
count++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment