Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use volatile in Kotlin

Tags:

kotlin

I tried something like this:

private volatile var instanceState: InstanceState = InstanceState.starts

Error:  'Expected member declaration'

and like this:

private volatile var instanceState: InstanceState = InstanceState.starts

Error:  'Property getter or setter expected'

Volatile not supported on Kotlin ?

like image 916
Ant20 Avatar asked Jun 16 '16 07:06

Ant20


1 Answers

Kotlin does not have a volatile keyword but an annotation: @Volatile (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-volatile/)

like image 67
Rafal G. Avatar answered Oct 13 '22 01:10

Rafal G.