idk the kotlin way =(
# android
m
idk the kotlin way =(
g
Maybe something like:
Copy code
@get:Synchronized
@set:Synchronized
var autoStartService = false
m
wat i tought at first, but i always heard its bad idea to syncronize a bool 😛
does my way work as well ?
e
You can use AtomicBoolean as well, instead of synchronizing a boolean
m
cool 😛 that might work
my lock works as well right? (appart from not being ideal)
g
Yes, AtomicBoolean probably good idea. But I don’t think that it’s bad in this case, because you don’t syncronize boolean value itself, only setters and getters. Also,
@set:Syncronized + @field:Volatile
should work, but actually AtomicBoolean is better