Each child coroutine is a separate coroutine and the same rule holds true. No two actions in the same coroutine can be concurrent. You typically confine mutable objects to a coroutine by syntactically enclosing them into a coroutine and ensuring they don’t leak to any other coroutines (including child coroutines). The closest analogue for Thread local with coroutines is a coroutine context.

Written by

Project Lead for the Kotlin Programming Language @JetBrains

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store