用懒汉式的说一下哈,,,,:P
-
- class Single
- {
- private static final Single s = null;
- private Single(){}
- public static Single gerInstance()
- {
- if(s==null)
- {
- synchronized(Single.clsaa)//该类所属的字节码文件对象
- {
- if(s==null)
- s = new Single();
- }
- }
- return s;
-
- }
- }
- class ThreadSingle
- {
- public static void main(String [] args)
- {
-
-
- }
- }
复制代码
如果是被静态修饰的那么就是本类对象的字节码文件,如果没有被静态修饰,就是任意的类,,,,,,:lol
|