How to Prevent Race Conditions in Coroutines

Thanks to structured concurrency, there are a lot of concerns that we don&rsquo;t have to handle manually when working with Kotlin coroutines. For example, parent coroutines automatically wait for their children to complete before completing themselves. And when a parent coroutine is cancelled, its children are automatically cancelled, too. But when it comes to shared mutable state - mutable data…