Improper Synchronization (ARCH8039)
Ce contenu n’est pas encore disponible dans votre langue.
Key kotlin.async.improper-synchronization · Severity warning · Category async
Flags synchronized on a String, boxed primitive or public object - locks that other code can also lock, or that are interned and shared.
Incorrect
Section titled “Incorrect”synchronized("lock") { }synchronized(this) { }Correct
Section titled “Correct”private val lock = Any()synchronized(lock) { }Lock on a private final Any() the class owns.