代码和视频一样,为什么控制台没有输出
package com.xuanxuan;
/**
* 使用Thread创建线程测试卖票
* @author Administrator
*
*/
class MyThread extends Thread{
private int ticketsCount=4;
private String name;
public MyThread(String name){
this.name=name;
}
//重写run()方法
public void run(){
while(ticketsCount>0){}
ticketsCount--;
System.out.println(name+"卖了一张票,还剩"+ticketsCount+"张票");
}
}
public class ThreadText {
public static void main(String[] args) {
// TODO Auto-generated method stub
//创建三个线程,模拟三个窗口卖票
Thread st1=new MyThread("小一");
Thread st2=new MyThread("小二");
Thread st3=new MyThread("小三");
//启动线程
st1.start();
st2.start();
st3.start();
}
}