Skip to content

Instantly share code, notes, and snippets.

@leviyehonatan
Last active March 13, 2021 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leviyehonatan/623c261f76bbd59abe401b67c4e78812 to your computer and use it in GitHub Desktop.
Save leviyehonatan/623c261f76bbd59abe401b67c4e78812 to your computer and use it in GitHub Desktop.
kotlin singleton
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