本帖最后由 杨增坤 于 2013-9-11 17:39 编辑
class TheredText
{
public static void main(String[] args)
{
MyThread myThread=new MyThread();
myThread.start();
}
}
class MyThread extends Thread
{
MyThread(){};
int i=0;
boolean flag=true;
public void run()
{
while(flag)
{
if(i<10000)
{
System.out.println("this is the input:" +i);
i++;
}
else
flag=false;
}
}
}
输出结果为:
this is the input:9701
this is the input:9702
this is the input:9703
this is the input:9704
this is the input:9705
this is the input:9706
this is the input:9707
this is the input:9708
this is the input:9709
this is the input:9710
this is the input:9711
this is the input:9712
this is the input:9713
this is the input:9714
this is the input:9715
this is the input:9716
this is the input:9717
this is the input:9718
this is the input:9719
this is the input:9720
this is the input:9721
this is the input:9722
this is the input:9723
this is the input:9724
this is the input:9725
问题一:为什么它的输出是从9701开始?
|