public test extends Thread
{  void run (void) {
    while(true) 
    {
      Thread.sleep(5*60*1000);
      // do something
      if (...) break;
    }
  }
}

解决方案 »

  1.   

    用<meta http-equiv=refresh content='100,url=test.jsp?id=1'>也可以,这里是100秒刷新一次,而且每次刷新都加上参数id=1,当然,你可以每次刷新都指定不同的参数
      

  2.   

    在win下面用计划任务
    unix下用cron
      

  3.   

    比如下面的代码每5分钟检查一遍是否有新邮件:        private java.util.Timer timer;
            timer = new Timer(true);        
            timer.schedule(new java.util.TimerTask() { 
               public void run() {                    
                     //server.checkNewMail(); 检查新邮件 }        
                }, 0, 5*60*1000);用的是Timer类!
      

  4.   

    支持zeeler(自乐) 同时,javascript中有个方法setTimeout(function, time)可以在某个时间段执行某个方法
      

  5.   


        Timer timer=new Timer(2000,new ActionListened({
          public void actionPerformed(ActionEvent e){
           System.out.println("Timer");
        }
        });
        while(true){
      timer.start();
    }
    }
    }
      

  6.   

    while( true ){
      xx() ;
      Thread.sleep( time ) ;
    }
    不过比较耗资源,最好在xx()里把他引用的资源释放
      

  7.   

    这个或许对你有启发import javax.swing.*;
    import java.awt.event.*;
    import java.util.Date;
    import java.util.Calendar;
    import java.text.SimpleDateFormat;
    import java.applet.Applet;
    import java.awt.*;public class TestTimer  extends Applet implements Runnable
    {
      public static int TT=2000;
    Thread t=null;
    boolean flag=false;

    public void paint(Graphics g)
    {
    //setColor(Color.blue);
        
      Calendar curcal = Calendar.getInstance();
      Date tmpTime =curcal.getTime();
    //SimpleDateFormat sdf = new SimpleDateFormat("HH:MM:SS");
    //String curTime = sdf.format(tmpTime);    g.drawString(tmpTime.toString(),11,33);
    g.setColor(new Color(1,2,3)); }  public void start()
    {
    flag=true;
    t=new Thread(this);
    t.start();
    }
    public void stop()
    {

    flag=false;
    }
    public void run(){
    while(flag)
    {
    try
    {
    Thread.sleep(999);//也可以设五分钟
    }catch(InterruptedException e)
    {}
    repaint();//可以调用要使用的bean...
    }
    }
      }