So I'm trying to get a handle on how Kotlin handles synchronization of properties. If I have this class:
class Foo {
var a = 0
var b = 0
}
and I want to make sure that a & b have all access synchronized. How would I do it? I've tried using the annotation:
class Foo {
@Synchronized
var a = 0
@Synchronized
var b = 0
}
but Kotlin gives me a compiler error:
This annotation is not applicable to target 'member property with backing field'
I'm just trying to get a better handle on thread safety in Kotlin. It's something that I've always been OCD about in Java, and I'm trying to figure out how to properly handle it in Kotlin.