Zensar Technologies Interview Question

Explain the creation of a thread-safe singleton in Java using double-checks locking

Interview Answer

Anonymous

Sep 26, 2018

Singleton is created with double checked locking as before Java 5 acts as an broker and it’s been possible to have multiple instances of Singleton when multiple threads creates an instance of Singleton at the same time. Java 5 made it easy to create thread-safe Singleton using Enum. Using a volatile variable is essential for the same.