日期:2014-05-20 浏览次数:20828 次
public class TestSeven extends Thread{
private static int x;
public static synchronized void doThings(){
int current = x;
current ++ ;
x = current;
}
public void run(){
this.doThings();
}
}
------解决方案--------------------
synchronized 是对同一对象才有作用
而你 创建了2个对象 所以不存在同步这个问题
所以1楼的改法是正确的
------解决方案--------------------
呵呵 学习了