singleton
-
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;
}
}
ekşi sözlük kullanıcılarıyla mesajlaşmak ve yazdıkları entry'leri
takip etmek için giriş yapmalısın.
hesabın var mı? giriş yap