package com.accp.xml;
public class A {
private static A a =null;
public static synchronized A getInstance(){
if(a == null){
a = new A();
return a;
}else{
return a;
}
}
Integer i = 0;
}
package com.accp.xml;
public class Test {
public static void main(String[] args) {
//equalsTest();
A a = A.getInstance();
a.i=3;
A b = A.getInstance();
b.i=100;
A c = new A();
c.i=200;
System.out.println("a.i="+a.i);//a.i=100
System.out.println("b.i="+b.i);//b.i=100
System.out.println("c.i="+c.i);//c.i=200
}
}