@@ -0,0 +1,1227 @@
+package singleton;%0A%0A/**%0A * Created by Miller on 2017/8/9 0009.%0A * %E5%8D%95%E4%BE%8B%E6%A8%A1%E5%BC%8F%0A */%0A%0A/**%0A * %E6%87%92%E6%B1%89%E6%A8%A1%E5%BC%8F%0A */%0A//public class Singleton %7B%0A//    private static Singleton instance;%0A//%0A//    public Singleton getInstance()%7B%0A//        if(instance == null)%7B%0A//            instance = new Singleton();%0A//        %7D%0A//%0A//        return instance;%0A//    %7D%0A//%7D%0A%0A/**%0A * %E9%A5%BF%E6%B1%89%E6%A8%A1%E5%BC%8F%0A */%0A//public class Singleton %7B%0A//    private static Singleton instance = new Singleton();%0A//    private Singleton ()%7B%7D%0A//    public static Singleton getInstance() %7B%0A//        return instance;%0A//    %7D%0A//%7D%0A%0A/**%0A * %E9%9D%99%E6%80%81%E5%86%85%E9%83%A8%E7%B1%BB%E7%9A%84%E6%96%B9%E5%BC%8F%0A */%0A//public class Singleton %7B%0A//    private static class SingletonHolder %7B%0A//        private static final Singleton INSTANCE = new Singleton();%0A//    %7D%0A//    private Singleton ()%7B%7D%0A//    public static final Singleton getInstance() %7B%0A//        return SingletonHolder.INSTANCE;%0A//    %7D%0A//%7D%0A%0A/**%0A * %E5%8F%8C%E9%87%8D%E6%A0%A1%E9%AA%8C%E9%94%81%0A */%0Apublic class Singleton%7B%0A    private volatile static Singleton singleton;%0A%0A    public  static Singleton getSingleton()%7B%0A        if(singleton == null)%7B%0A            synchronized(Singleton.class)%7B%0A                if(singleton == null)%7B%0A                    singleton = new Singleton();%0A                %7D%0A            %7D%0A        %7D%0A%0A        return singleton;%0A    %7D%0A%7D

add singleton pattern