java提供了import javax.swing.Timer;中有个Timer类你只要定义:ActionListener listener=new TimePrinter();
           Timer t=new Timer(100,listener);//100指的是100毫秒
然后监听事件:
    private class TimePrinter implements ActionListener
    {
     public void actionPerformed(ActionEvent event)
     {
              run();//每100毫秒发生一次
     }
    }

解决方案 »

  1.   

    java.util.Timer类public void scheduleAtFixedRate(TimerTask task,
                                    long delay,
                                    long period)
      

  2.   

    给你个例子吧:
    import java.util.*;
    class matimerTask extends TimerTask{
      public void run(){
        System.out.println("timer task executed");
      }
    }class ttest{
      public static void main(String[] args){
        myTimerTask mytask=new myTimerTask();
        Timer mytimer=new Timer();
        mytimer.schedule(mytask,1000,500);//程序开始一秒后每个半秒执行mytask一次
        try{
          Thread.sleep(5000);
        }catch(InterruptedException exc){}
        mytimer.cancel();
      }
    }
      

  3.   

    恩 TongNi(小白  说的已经够详细的了 应该可以了
      

  4.   

    sorry,忘记了还有一句:   定义完后Timer加上: t.start();