<Why is this working? (generating values in main t...
# stackoverflow
u
Why is this working? (generating values in main thread and consuming them in some other background thread in Android) As far as I know, threads copy variables in their local cache. What I'm doing is, I'm getting values in the main thread and then I'm consuming them in some other background (renderer) thread. Like this- class MySurfaceView ... { private var someValue = 0 // Called from the main thread fun updateValue() { someValue++ } fun render() { Thread { // Here someValue variable is consumed // and it's always up to date. .......