Created
November 21, 2013 10:24
-
-
Save theShadow89/7579296 to your computer and use it in GitHub Desktop.
Singleton
This file contains hidden or 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 static Singleton istanza = null; | |
//Il costruttore private impedisce l'istanza di oggetti da parte di classi esterne | |
private Singleton() {} | |
// Metodo della classe impiegato per accedere al Singleton | |
public static synchronized Singleton getSingleton() { | |
if (istanza == null) | |
istanza = new Singleton(); | |
return istanza; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment