首页 > 其他 > 详细

1.单例模式

时间:2015-06-24 00:36:46      阅读:275      评论:0      收藏:0      [点我收藏+]

1.定义

Ensure a class has only one instance,and provide a global point of access to it.(确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例。)

2.模式讲解

(1)类图

技术分享

(2)单例模式通用代码

 1 public class Singleton
 2 {
 3     private static Singleton singleton = new Singleton();
 4 
 5     private Singleton()
 6     {}
 7 
 8     public static Singleton GetSingleton()
 9     {
10         return singleton;
11     }
12 }

3.单例模式的多种实现方式(待续)

http://terrylee.cnblogs.com/archive/2005/12/09/293509.html

1.单例模式

原文:http://www.cnblogs.com/JustYong/p/4596536.html

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