我想用下面的代码实现test.class只能创建一个实例。
但是好像不起作用。
synchronized(a)这个地方为什么不能同步。
我两次启动test,两次都可以创建实例。需要怎么改才能实现?
import java.util.*;
import java.text.*;
import java.util.Map;
import java.util.HashMap;public class test{
    static Integer a = new Integer(0);
    public static void main(String[] args) {
synchronized(a){
testThread tt = new testThread();
tt.start();
}
     }
}class testThread extends Thread{
private static Object obj = new Object(); public testThread(){
}

public void run(){
synchronized(obj){
try{
System.out.println("Sleep start");
sleep(10000);
System.out.println("Sleep end");
}catch(Exception e){
}
}
}
}