多线程-单例设计模式懒汉 饿汉
2016-06-01 23:16
387 查看
饿汉 class Single{ private static final Single s = new Single(); private Single(); private static Single getInstance(){ return a; } } 懒汉 class Single { private static Single s= null; private Single(){} public static Single getInstance){ if(s == null){ synchronized (Single.class){ if(s == null){ s = new Single(); } } } return s; } }
相关文章推荐
- JS学习21(离线应用与客户端储存)
- iOS中关于atomic和nonatomic,assign、weak、strong、retain的使用、区别
- Linux Common Comment in Practices
- python 2.7后的字符串赋值
- 嵌套json
- 远程服务器:PHP5.5+apache2.4+SQL SERVER2008开发环境配置
- Python 实现栈
- 多线程通讯-等待唤醒机制
- android中handler用法总结(http://blog.sina.com.cn/s/blog_77c6324101016jp8.html)
- 多线程(停止线程)
- The database returned no natively generated identity value 错误的解决
- scala学习手记4 - Java基本类型对应的scala类
- Sql递归查询
- poj 1477(超级水题)
- 杨辉三角
- 数字分类
- Volley使用说明与简单分析
- JAVA异常处理
- 发发牢骚
- css中的max-width