线程问题,为什么每次的运行结果不一样?
public class ThreadTest implements Runnable { public static int a = 0;
public void run() {
for (int k = 0; k < 5; k++) {
a = a + 1;
}
}
public static void main(String[] args) {
Runnable r = new ThreadTest();
Thread t = new Thread(r);
t.start();
System.out.println("first"+a);
}
}
first 出现的位置每次不一样,怎么 不是先运行线程,再运行first+a么??