a
- public class T22 {
- /**
- * 懒汉式
- */
- public static void main(String[] args) {
- }
- }
- class Singleton{
- private Singleton(){};
- private static Singleton s = null;
- public static Singleton getInstance(){
- if(s==null){
- synchronized(Singleton.class){
- if(s==null)
- s = new Singleton();
- }
- }
- return s;
- }
- }
复制代码
|
|