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开始?
作者: 肖勇 时间: 2013-9-9 09:23
这只是计算机的运行速度太快,控制台只能容下那么多数据,当他运行的时候你可以强行终止,然后看下结果。this is the input:1949this is the input:1950
this is the input:1951
this is the input:1952
this is the input:1953
this is the input:1954
this is the input:1955
this is the input:1956
this is the input:1957
this is the input:1958
this is the input:1959
this is the input:1960
this is the input:1961
this is the input:1962
this is the input:1963
this is the input:1964
this is the input:1965
this is the input:1966
this is the input:1967
this is the input:1968
this is the input:1969
this is the input:1970
this is the input:1971
this is the input:1972