IDE是Eclipse,语言是JAVA,Release下执行,
a的结果是5,确定是有至run()函式中执行,可是在Debug模式下,
却无法跳至run()函式中,似乎 跟mthread.join();这行有关,
请问有人知道为什么吗?
public class mythread 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) throws Exception {
Runnable r = new mythread();
Thread mthread = new Thread(r);
mthread.start();
mthread.join();
System.out.println(a);
}
}