Java Singleton and Synchronization
Please clarify my queries regarding Singleton and Multithreading: What is the best way to implement Singleton in Java, in a multithreaded environment? What happens when multiple threads try to access getInstance() method at the same time? Can we make singleton's getInstance() synchronized ? Is synchronization really needed, when using Singleton classes? Jeffrey Yes, it is necessary. There are several methods you can use to achieve thread safety with lazy initialization: Draconian synchronization: private static YourObject instance; public static synchronized YourObject getInstance() { if