y
07/26/2024, 2:49 PMobject Foo {
@Synchronized
fun f() {
doThing1()
doThing2()
doThing3()
}
}
vs.
object Foo {
fun f() {
synchronized(this) {
doThing1()
doThing2()
doThing3()
}
}
}
Chris Lee
07/26/2024, 3:01 PMobject
the synchronized(this)
is over the single instance, which mirrors what @Synchronized would do for a static method.CAB
07/27/2024, 7:56 PMChris Lee
07/27/2024, 7:58 PM