https://kotlinlang.org logo
#getting-started
Title
# getting-started
d

Daeyoung Kim

03/05/2022, 7:49 AM
Copy code
class Singleton private constructor(config: SingletonConfig){
    companion object {
        @Volatile private var instance: Singleton? = null

        fun sharedEngineWithConfig(config: NgpConfig): Singleton =
            instance ?: synchronized(this) {
                instance ?: Singleton(config).also {
                    instance = it
                }
            }
    }
}
🧵 2