首页 > 其他 > 详细

单例模式

时间:2015-12-16 12:04:20      阅读:156      评论:0      收藏:0      [点我收藏+]
 1 public class SingleInstance
 2 {
 3     private static SingleInstance singleInstance = null;
 4     private static readonly object locker = new object();
 5     private SingleInstance()
 6     { 
 7     }
 8     public static SingleInstance getInstance()
 9     {
10         lock (locker)
11         {
12             if (singleInstance == null)
13                 return new SingleInstance();
14         }
15         return singleInstance;
16     }
17 }

 

单例模式

原文:http://www.cnblogs.com/foreverApril/p/5050525.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!