单例的种种情况
摘要:
单例模式(Singleton):保证一个类仅有一个实例,并提供一个访问它的全局访问点。单例模式(单件模式) 使用方法返回唯一的实例 public class SingLeton { //创建一个私有的构造函数(必须),堵住外界使用new创建此实例的可能 private SingLeton() { } private static SingLeton instance; public static SingLeton GetInstance() { if (instance ==null ) { instance = new SingLeton(); } return instance; } } 阅读全文
posted @ 2012-07-31 22:02 前总2012 阅读(124) 评论(0) 推荐(0) 编辑