码迷,mamicode.com
首页 > 其他好文 > 详细

单例模式

时间:2015-12-16 12:06:39      阅读:151      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!