jasu's blog
블로그 메뉴글
Singleton
Programming/Design Patterns
2007. 2. 21. 11:08
1 class Singleton{
2 private static var uniqueInstance;
3
4 private function Singleton(){
5
6 }
7 public static function getInstance():Singleton{
8 if(uniqueInstance == null){
9 uniqueInstance = new Singleton();
10 }
11 return uniqueInstance;
12 }
13 public function getName(){
14 trace("Singleton pattern");
15 }
16 }
2 private static var uniqueInstance;
3
4 private function Singleton(){
5
6 }
7 public static function getInstance():Singleton{
8 if(uniqueInstance == null){
9 uniqueInstance = new Singleton();
10 }
11 return uniqueInstance;
12 }
13 public function getName(){
14 trace("Singleton pattern");
15 }
16 }