kotlinx.coroutines icon indicating copy to clipboard operation
kotlinx.coroutines copied to clipboard

Docs: change volatile example to use IO, not Default

Open aSemy opened this issue 3 years ago • 0 comments
trafficstars

When I run this example

https://kotlinlang.org/docs/shared-mutable-state-and-concurrency.html#volatiles-are-of-no-help

it regularly returns the exact amount, 100000.

See also: https://old.reddit.com/r/Kotlin/comments/v4j01h/volatile_works_in_coroutine/

This seems to happen more often when I run the code on my mobile... but that's a guess.

When I change Dispatchers.Default to Dispatchers.IO it appears to demonstrate the problem more reliably.

I've marked this a draft because I wasn't sure if this was the only place the Dispatcher should change

  • [ ] Should the Dispatcher in the other examples also be changed?

aSemy avatar Jun 04 '22 08:06 aSemy