Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Singleton {
- private static volatile Singleton instance;
- public static Singleton getInstance() {
- Singleton localInstance = instance;
- if (localInstance == null) {
- synchronized (Singleton.class) {
- localInstance = instance;
- if (localInstance == null) {
- instance = localInstance = new Singleton();
- }
- }
- }
- return localInstance;
- }
- }
Add Comment
Please, Sign In to add comment