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

设计模式——单例模式

时间:2016-07-25 00:10:42      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

 1     internal class SingletonOne
 2     {
 3         private static SingletonOne _singleton;
 4         private SingletonOne()
 5         {
 6         }
 7 
 8         public static SingletonOne Instance
 9         {
10             get
11             {
12                 if (_singleton == null)
13                 {
14                     Interlocked.CompareExchange(ref _singleton, new SingletonOne(), null);
15                 }
16 
17                 return _singleton;
18             }
19         }
20     }

 

设计模式——单例模式

标签:

原文地址:http://www.cnblogs.com/jaysen/p/5701979.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!