每个线程加个sleep(5)语句试试。

解决方案 »

  1.   

    void button2_actionPerformed(ActionEvent e) {
    dourl doit=new dourl();
    doit.doit();
      }
    void button3_actionPerformed(ActionEvent e) {
    System.exit(0);
    }
    其中按钮2就是程序运行,它是一个死循环程序,但是我已经在循环里加入了if(Thread.activeCount()>10)
    {
      try{Thread.currentThread().wait();}
      catch(InterruptedException abcd)
      {
      }
    }
    try{Thread.currentThread().sleep(1000);}
    catch(InterruptedException abc)
    {}可是程序按钮3依然不响应....就是点都不让点的那种
      

  2.   

    if(Thread.activeCount()>10)
    {
          java.util.Date thisTime=new java.util.Date();
          java.util.Date lastTime=new java.util.Date();
          lastTime.setTime(System.currentTimeMillis());
          thisTime.setTime(System.currentTimeMillis());
         //执行的代码
          Thread.sleep(1000);
          lastTime.setTime(thisTime.getTime());
    }