Here is my sample abstract singleton class:
public abstract class A {
protected static A instance;
public static A getInstance() {
return ins
In addition to problems others have pointed out, having the instance field in A means that you can only have one singleton in the entire VM. If you also have:
public class C extends A {
private C() { }
static {
instance = new C();
}
//...implementations of my abstract methods...
}
... then whichever of B or C gets loaded last will win, and the other's singleton instance will be lost.
This is just a bad way to do things.