4 entry daha
  • sanirim ilk olarak gof (gang of four) diye adlandirlan bir dörtlü ekip tarafindan "design patterns" kitabinda yayinlanmistir.
    bir de thread-safe versiyonu vardir:

    pubic class singleton{
    private final static theinstance = new singleton();
    private singleton() {
    }
    public static singleton getinstance() {
    return theinstance;
    }
    }

    yada:

    class singleton{
    private final static theinstance;
    private singleton() {
    }
    public synchronized static singleton getinstance() {
    if (theinstance == null) {
    theinstance = new singleton();
    }
    return theinstance;
    }
    }
53 entry daha
hesabın var mı? giriş yap