Implement a thread-safe singleton in Java and discuss Kotlin approaches.
Unlock detailed company stats for this questionUpgrade
Started with what a singleton class is and implemented a basic singleton in Java, then discussed how to make it thread-safe. Then Kotlin approaches: an object declaration, a Java-style singleton and a synchronized block, noting that synchronized is JVM-specific, so Kotlin Multiplatform targets would need platform-specific locking.
Format · Technical interview.
Community answers
No answers contributed by the community yet.
Related questions
Implement a thread-safe singleton.Implement a thread-safe LRU cache in C++.Design and implement a thread-safe message queue.Related courses

Course

Course
Course
