日期:2014-05-19  浏览次数:20756 次

初学求解 卖票程序出错
class Tickets implements Runnable
{
  private int num=100;
  public void run();
  {
  while(true)
  {
  if(num>0)
  {
  System.out.println(Thread.currentThread().getName()+".........."+num--);
  } 
  }
  }
}
class ThreadDemo
{
 public static void main(String [] args)
 {
  Tickets t = new Tickets();
  Thread m1 = new Thread(t);
  Thread m2 = new Thread(t);
  Thread m3 = new Thread(t);
  Thread m4 = new Thread(t);
  m1.start();
  m2.start();
  m3.start();
  m4.start();
 }
}

------解决方案--------------------
两个错误:
1、public void run(); 后面这个分号拿来干啥?删掉!
2、class ThreadDemo 怎么漏了public,没有public的main()函数无法启动。