Skip to content

Instantly share code, notes, and snippets.

@theShadow89
Created November 21, 2013 10:24
Show Gist options
  • Save theShadow89/7579296 to your computer and use it in GitHub Desktop.
Save theShadow89/7579296 to your computer and use it in GitHub Desktop.
Singleton
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