eclipse中两个进程不能同时进行,为什么?
public class TestThreadDemo {public static void main(String[] args)
{
new TestThread().start();
for(int i=1;i<=10;i++)
System.out.println("The main is running!");
}
}
class TestThread extends Thread
{
public void run()
{
for(int i=1;i<=10;i++)
System.out.println("The TestThread is running!");
}
}
这是结果:
The main is running!
The main is running!
The main is running!
The main is running!
The main is running!
The main is running!
The main is running!
The main is running!
The main is running!
The main is running!
The TestThread is running!
The TestThread is running!
The TestThread is running!
The TestThread is running!
The TestThread is running!
The TestThread is running!
The TestThread is running!
The TestThread is running!
The TestThread is running!
The TestThread is running!
应该是两个进程交替的来啊,怎么是一个完了才是另一个呢 跟教科书上的不一样哦