I am new to Kotlin. Still learning basic syntax. I've heard about companion objects similar to static in Java. But don't know how to create synchronized singleton in Kotlin.
Just use
object Singleton {
// any members you need
}
It's already synchronized properly:
Object declaration's initialization is thread-safe.
Note that this doesn't guarantee calls on it thread-safe, but that's just as in Java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With