Created
January 11, 2010 15:02
-
-
Save mvaz/274293 to your computer and use it in GitHub Desktop.
Thread-safe singleton pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Singleton { | |
private Singleton INSTANCE; | |
public static Singleton getInstance() { | |
if ( instance == NULL ) { | |
synchronized(Singleton.class) { | |
INSTANCE = new Singleton(); | |
} | |
} | |
return INSTANCE; | |
} | |
private Singleton() { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment