How to create a thread-safe singleton in Java using double-checked locking?
Anonymous
Singleton created with double checked locking before Java 5 was a broker and it's possible to have multiple instances of Singleton if multiple threads try to create an instance of Singleton at the same time. from Java 5 it's easy to create thread-safe Singleton using Enum. but if interviewer persists with double checked locking then you have to write that code for them. remember to use a volatile variable. See 10 Java singleton interview question for more details on this topic.
Check out your Company Bowl for anonymous work chats.