Volatile properties in Kotlin?

According to the Kotlin documentation Kotlin-@Volatile

Marks the JVM backing field of the annotated property as volatile, meaning that writes to this field are immediately made visible to other threads.

So, in Kotlin you can mark the property as volatile with @Volatile annotation.

e.g.

@Volatile var tmpEndedAt: Long? = null

I decided to give Kotlin a shot by just using the "convert java to kotlin" function in IntelliJ. Apparently that set things up wrong.

I tried doing the same thing, but after applying the Kotlin Gradle plugin and placing the file in src/kotlin and it all worked. Thanks for the help anyway guys.

The code would be:

@Volatile var tmpEndedAt: Long? = null

Tags:

Kotlin