public class SingletonTest {
private static SingletonTest stTest = null;
public static SingletonTest getInstance() {
if( stTest == null ){
stTest = new SingletonTest();
}
return stTest;
}
public static void main(String[] args) {
SingletonTest tmpInstance = SingletonTest.getInstance();
}
}
* public static synchronized SingletonTest getInstance() { //이렇게 하면 한번에 하나만 실행된다.더보기
http://www.ibm.com/developerworks/kr/library/j-dcl.html
'JAVA야' 카테고리의 다른 글
| LinkedHashMap 순서가 있는 hash (0) | 2009.12.07 |
|---|---|
| replace(1.4이전에서 구현) (0) | 2009.12.07 |
| 리플렉션 (0) | 2009.12.07 |
| XML을 파싱해보자~ (0) | 2009.09.02 |
| [복사되는블로그 꼬마갱이]Tomcat 시작시 Class시작 (0) | 2009.08.06 |