一个简单的多线程问题
public class ThreadTest implements Runnable {
int a;
public void run() {
for(a=0;a<10;a++){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
System.out.println(Thread.currentThread().getName() + " a=" + a);
}
}
public static void main(String[] args) {
ThreadTest run=new ThreadTest();
Thread thread1=new Thread(run);
Thread thread2=new Thread(run);
Thread thread3=new Thread(run);
Thread thread4=new Thread(run);
Thread thread5=new Thread(run);
Thread thread6=new Thread(run);
thread6.start();
thread1.start();
thread2.start();
thread3.start();
thread4.start();
thread5.start();
}
}
为什么会输出到a=14啊