0
スレッドの停止
次のプログラムを?と?で実行した結果が違います。どう理解したらよいでしょうか?
ご教示の程宜しくお願いします。
class ExitThread extends Thread {
public void run(){
boolean running = true;
while (running){
for ( int i=0; i<10; i++ ) {
System.out.println(i);
// ? if ( i == 5 ) running = false;
// ? if ( i == 5 ) return;
}
}
}
public static void main (String[] args){
ExitThread et = new ExitThread();
et.start();
}
}
?の実行結果
run:
0
1
2
3
4
5
6
7
8
9
ビルド成功
?の実行結果
run:
0
1
2
3
4
5
ビルド成功