Last active
March 13, 2021 16:38
-
-
Save leviyehonatan/623c261f76bbd59abe401b67c4e78812 to your computer and use it in GitHub Desktop.
kotlin singleton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class YoloObjectDetection private constructor(context: Context) { | |
companion object { | |
@Volatile private var INSTANCE: YoloObjectDetection? = null | |
fun getInstance(context: Context): YoloObjectDetection = | |
INSTANCE ?: synchronized(this) { INSTANCE ?: YoloObjectDetection(context).also { INSTANCE = it}} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment