请教一个线程的问题
class Lt9_2
{
public static void main(String args[])
{
People teacher=new People(),
student=new People();
for(int i=1;i<=5;i++)
{
teacher.start();
student.start();
}
}
}
class People extends Thread
{
public void run()
{
if(Thread.currentThread().getName().equals("teacher"))
{
System.out.println("我是老师");
}
else if(Thread.currentThread().getName().equals("student"))
{
System.out.println("我是学生");
}
}
}
编译时报错:
Exception in thread "main" java.lang.IllegalThreadStateException
at java.lang.Thread.start(Thread.java:571)
at Lt9_2.main(ThreadTest.java:470)
Process completed.
请问是什么错呢?应该怎么改?
[此贴子已经被作者于2007-11-2 12:28:13编辑过]