你的编程思想还有待进步。
同步的变量或操作不要写在线程里。 你在你的Test里把这些读取,加减,分别封装好,在这些读取,加减的方法上加synchronized 就行了。
理解一下生产者和消费者的这个线程同步例子
while(Test.i < Test.len){
//System.out.println(Test.i);
prin(Test.i++);
// Test.i++;
}
这样试试
synchronized
Test.i++;也封装进prin(int i)方法里试试