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

我在JAVA教程里按他的例程,编写了,怎么一运行就会响运慢了!
希望高手帮忙指点一下,我现在是刚开始学,高手多帮忙啊!
下面是程序代码
public class ThreadDemo9_4
{
  public static void main(String[]args)
  {
  TestThread t=new TestThread();
  new Thread(t).start();
  new Thread(t).start();
  new Thread(t).start();
  new Thread(t).start();
  }
}
class TestThread implements Runnable
{
  private int tickets=20;
  public void run()
  {
  while(true)
  {
  if(tickets>0)
  System.out.println(Thread.currentThread().getName()+"出售票"+tickets--);
  }
  }
}


------解决方案--------------------
这个方法是调用了线程休眠,休眠了当然慢了