Writing /volume1/Web/Public/dokuwiki/data/log/deprecated/2024-11-15.log failed

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
study:java:design_pattern:singleton [2010/03/10 13:13] bananastudy:java:design_pattern:singleton [2014/01/09 00:12] (現在) banana
行 22: 行 22:
 고전적인 싱글턴 구현법을 소개합니다. 고전적인 싱글턴 구현법을 소개합니다.
 <code java> <code java>
-public class Singleton{+public class Singleton {
      private static Singleton uniqueInstance;      private static Singleton uniqueInstance;
  
-     private Singleton(){}+     private Singleton() {}
  
-     public static Singleton getInstance(){ +     public static Singleton getInstance() { 
-         if(uniqueInstance == null){+         if (uniqueInstance == null) {
               uniqueInstance = new Singleton();               uniqueInstance = new Singleton();
          }          }
行 49: 行 49:
 다음의 코드를 살펴보세요. 다음의 코드를 살펴보세요.
 <code java> <code java>
-public class Singleton{+public class Singleton {
      private static Singleton uniqueInstance;      private static Singleton uniqueInstance;
  
-     private Singleton(){}+     private Singleton() {}
  
-     public static synchronized Singleton getInstance(){ +     public static synchronized Singleton getInstance() { 
-         if(uniqueInstance == null){+         if (uniqueInstance == null) {
              uniqueInstance = new Singleton();              uniqueInstance = new Singleton();
          }          }
行 89: 行 89:
  
 <code java> <code java>
-public class Singleton{+public class Singleton {
      private static Singleton uniqueInstance = new Singleton();      private static Singleton uniqueInstance = new Singleton();
  
-     private Singleton(){}+     private Singleton() {}
  
-     public static Singleton getInstance(){+     public static Singleton getInstance() {
          return uniqueInstance;          return uniqueInstance;
      }      }
行 110: 行 110:
  
 <code java> <code java>
-public class Singleton{+public class Singleton {
     private volatile static Singleton uniqueInstance;     private volatile static Singleton uniqueInstance;
  
-    private Singleton(){}+    private Singleton() {}
  
-    public static Singleton getInstance(){ +    public static Singleton getInstance() { 
-        if(uniqueInstance==null){ +        if (uniqueInstance == null) { 
-            synchronized(Singleton.class){ +            synchronized(Singleton.class) { 
-                if(uniqueInstance==null){+                if (uniqueInstance == null) {
                      uniqueInstance = new Singleton();                      uniqueInstance = new Singleton();
                 }                 }

QR Code
QR Code study:java:design_pattern:singleton (generated for current page)