반응형

유용하면서 간단한 디자인패턴 : 싱글톤 패턴

 

Singleton class  Basic type

 

 

public class Singleton {
	private volatile static Singleton uniqueInstance = null;
	
	private Singleton() {}
	public static Singleton getInstance (){
		if ( uniqueInstance == null){
			synchronized( Singleton.class){
				if (uniqueInstance == null)
					uniqueInstance = new Singleton();
			}
		}
		return uniqueInstance;
	}
}

 

 

 

'개발 Note > Codes' 카테고리의 다른 글

[Andriod] Timer and TimerTask  (0) 2020.10.22
sorting algorithms  (0) 2014.02.26
UML2 Sementics  (0) 2012.01.11

+ Recent posts