黑马程序员-多线程-11天-3
2013-04-07 22:32
176 查看
/* 单例设计模式。 */ //饿汉式。 /* class Single { private static final Single s = new Single(); private Single(){} public static Single getInstance() { return s; } } */ //懒汉式 class Single { private static Single s = null; private Single(){} public static Single getInstance() { if(s==null) { synchronized(Single.class) { if(s==null) //--->A; s = new Single(); } } return s; } } class SingleDemo { public static void main(String[] args) { System.out.println("Hello World!"); } }
相关文章推荐
- 黑马程序员---Java基础--11天(多线程)
- 黑马程序员-多线程-11天-1
- 黑马程序员-多线程-11天-2
- 黑马程序员--JAVA基础复习之多线程(一)概念与创建方法
- 黑马程序员-多线程
- 黑马程序员Java__多线程
- 多线程11天--04
- 黑马程序员---多线程
- 多线程11天--15
- 黑马程序员_多线程
- 【黑马程序员】java多线程学习总结
- 黑马程序员_java多线程
- 黑马程序员——Java多线程—Callable、Future
- 黑马程序员——多线程知识总结
- 黑马程序员——Java基础---多线程
- 黑马程序员_多线程
- 黑马程序员-多线程
- 黑马程序员_java多线程总结
- 黑马程序员——Java多线程
- 黑马程序员8. 多线程