public class MySingleton {
private static MySingleton me = new MySingleton();
private MySingleton() {
// do something if you want
}
public static MySingleton getInstance() {
return me;
}
public void doSomething() {
System.out.println("I am a stupid method");
}
}
This implementation is considered thread safe.