单例模式

 1 public class Singleton {
 2 
 3     private static Singleton singleton ;
 4     
 5     private Singleton(){}
 6     
 7     public static Singleton getInstance(){
 8         
 9         if(singleton == null){
10             
11             singleton = new Singleton();
12             
13         }
14         return singleton;
15     }
16 }

 

posted @ 2016-09-22 14:19  SpringMVCMaven  阅读(207)  评论(0编辑  收藏  举报