代码如下,为什么程序不能输出end ,求指点
public class Test{
public static void main(String args[]){
R r=new R();
Thread t=new Thread(r);
t.start();
while(!r.terminate){
}
System.out.println("end");
}
}
class R implements Runnable{
public boolean terminate=false;
public void run(){
int x=0;
while(x<1000){
x++;
System.out.println(x);
}
terminate=true;
}
}