jschneider
06/20/2017, 9:19 PMdiesieben07
06/20/2017, 9:22 PMfun getName
should really be a val name
with a getter. And then check out the extension functions on ReentrantReadWriteLock
that the standard library provides: http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.concurrent/java.util.concurrent.locks.-reentrant-read-write-lock/index.htmlnkiesel
06/21/2017, 12:05 AMimport java.util.concurrent.locks.ReentrantReadWriteLock
import kotlin.concurrent.*
class K {
private val lock = ReentrantReadWriteLock()
var name = "initial"
get() = lock.read { field }
set(new) = lock.write { field = new }
}