Triple King

好记性不如烂笔头,曾经学习到的东西都是一笔财富,有空时不妨记录下来。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2013年6月27日

摘要: 单例模式确保一个类只有一个实例,并提供一个全局访问点。类图:Singletonstatic uniqueInstance//其他属性...static getInstance()//其他方法...使用单例模式得需要考虑到多线程环境下的问题,以下为几种解决方法:1、同步getInstance()public class Singleton{ private static Singleton uniqueInstance; private Singleton(){} public static synchronized Singleton ... 阅读全文

posted @ 2013-06-27 22:06 TripleKing 阅读(160) 评论(0) 推荐(0)