You can mark a property as volatile with @Volatile annotations:
@Volatile var name:String = "stack"
The resulting field declaration is equivalent to Java:
private volatile java.lang.String name;
According to @Volatile docs:
Marks the JVM support field of the annotated property as volatile, so that writing to this field immediately becomes visible to other topics.
miensol
source share