为什么我的代码和老师的一样就是报错!!!!!为什么
public class ActorCopy extends Thread
{
public void run()
{
System.out.println(getName()+"是一个演员!");
boolean keepRunning=true;
int count=0;
while(keepRunning)
{
System.out.println(getName()+"第"+(count+1)+"登台演出");
count++;
if(count==100)
keepRunning=false;
if(count%10==0)
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
System.out.println(getName()+"结束演出!");
}
public static void main(String [] args)
{
Thread Actor=new ActorCopy();
Actor.setName("刘德华");
Actor.start();
Thread actressThread=new Thread(new Actress(),"汤唯");
actressThread.start();
}
class Actress implements Runnable
{
@Override
public void run() {
System.out.println(Thread.currentThread().getName()+"是一个女演员!");
Boolean keepRunning=true;
int count =0;
while(keepRunning)
{
System.out.println(Thread.currentThread().getName()+"第"+(count+1)+"次登台演出!");
count++;
if(count%10==0)
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(count ==100)
keepRunning=false;
}
System.out.println(Thread.currentThread().getName()+"结束演出!");
}
}
}
为什么我的代码和老师的一样就是报错!!!!!为什么