为什么这里运行不出来,是我 new Thread(ticke,"小明").start();这一句出错了吗?该怎么修改?
package test;
//模拟购买火车票
class Ticke implements Runnable{
private int TickeNums=10;
public void run() {
while(true) {
if(TickeNums<=0) {
break;
}//模拟延时
try {
Thread.sleep(20000);
}catch(InterruptedException e){
System.out.println("出现异常");
}
}
System.out.println(Thread.currentThread().getName()+"--拿到了第"+TickeNums+"票");
}
}
public class test5 {
public static void main(String[] args) {
Ticke ticke=new Ticke();
new Thread(ticke,"小明").start();
}
}