How does one mark a var in Kotlin volatile?

volatile public var tmpEndedAt: Long? = null

Is giving me the error: "unresolved reference: volatile".

推荐答案

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

Kotlin相关问答推荐

如何在 Kotlin 中初始化 Short 数组?

Ktor 在 Heroku 上的 CORS 问题,但在本地没有

如何从 Period.between() 返回的字符串中提取信息? (Kotlin )

Kotlin 函数有 2 个参数用于对 Map 或 List 进行排序

当 func 重载时,kotlin 如何确定调用哪个 func?

Kotlin 数据类中的大量参数

在 Kotlin 中,为什么在 `+` 之前但在 `.` 之前没有换行符?

高效匹配两个 Flux

KMM:编译失败:意外的 IrType 类型:KIND_NOT_SET

无法从 XML 访问 NavHostFragment

Firebase 权限被拒绝

如何在 Android Studio 3.1.3 中查看 Kotlin 中有趣的源代码?

如何在Android Studio 4.1中默认启用Kotlin Android扩展

spring.config.location 在 Spring Boot 2.0.0 M6 上不起作用

Kotlin - computed var 属性的用处?

Kotlin中的属性(properties)和参数(parameters)有什么区别?

尾随 lambda 语法(Kotlin)的目的是什么?

Kotlin 是否支持部分应用程序?

Kotlin:在何时使用枚举

Kotlin:如何使用扩展函数扩展枚举类