你要用在什么架构的系统下?b/s、c/s还是简单的application?

解决方案 »

  1.   

    我就是自己做的,用时间吧。java中有个timer,不过我不用,烦,自己写还明显简单
      

  2.   

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;public class TimeTest implements ActionListener
    {
    private int seconds = 1;
    public TimeTest()
    {
    Timer oneSecondTimer = new Timer(1000,this);
    Timer timerWithInitialDelay = new Timer(2000,new TimerWithDelayListener());
    Timer oneTimeTimer = new Timer(10000,new OneTimeListener());

    timerWithInitialDelay.setInitialDelay(5000);
    oneTimeTimer.setRepeats(false);

    oneSecondTimer.start();
    timerWithInitialDelay.start();
    oneTimeTimer.start();
    }

    public void actionPerformed(ActionEvent e)
    {
    if(seconds == 0)
    System.out.println("Time:" + seconds + " second");
    else
    System.out.println("Time:" + seconds + " seconds");
    seconds++;
    }

    public static void main(String[] args)
    {
    new TimeTest();
    while(true);
    }

    }class TimerWithDelayListener implements ActionListener
    {
    public void actionPerformed(ActionEvent e)
    {
    System.out.println("Timer whit Delay Ringing");
    }
    }class OneTimeListener implements ActionListener
    {
    public void actionPerformed(ActionEvent e)
    {
    System.out.println("One Time Timer Ringing");
    }
    }
      

  3.   

    To chenyuan_Tongji是简单applicationTo deadrock自己怎么写呢
      

  4.   

    可以用 java.util.Timer 和 java.util.TimerTask。你需要实现 TimerTask,然后将你实现 TimerTask 实例加入 Tiemr 中。如果你每次只触发一件事情的吧,可以用 java.swing.Timer,它是通过触发 ActionListener 来执行事情的。