代码如下:
public class MultiThreadError implements Runnable{
static MultiThreadError instance = new MultiThreadError();
int index = 0;
public static void main(String[] args) throws InterruptedException {
Thread thread1 = new Thread(instance);
Thread thread2 = new Thread(instance);
thread1.start();
thread2.start();
thread1.join();
thread2.join();
System.out.println(instance.index);
}
@Override
public void run() {
for (int i = 0; i < 10000; i++) {
index ++;
}
}
}
麻烦老师看下是什么问题