When it comes to singleton, it is one of the most frequently asked Java question. There are multiple ways to ensure singleton behavior in multi-threaded environment like
-
- Making a variable public static final
- Making a synchronized getInstance method
- Double checked getInstance method
- Using Enums