public class Singleton {
private static final Singleton _theInstance = new Singleton();

private Singleton() {
}

public static Singleton getInstance() {
return _theInstance;
}
}
The Java spec guarantees that the static initialiser will be executed only once, at class load time.

Advertisements