请问如何用多线程显示当前的时间!
请各位写出来!

解决方案 »

  1.   

    不要多线程就可以显示啊,
    Thread(1000)
      

  2.   

    不好意思啊,打错了,应该是Thread.sleep(1000)
      

  3.   

    JLable lbltime=new JLable ();
    Date dt = new Date();
    lbltime .setText("当前日期:" + dt.toGMTString());
    Thread.sleep(1000);
      

  4.   

    不会gui,所以贴个command窗口的
    import java.util.*;
    public class test{
    public static void main(String[] args)throws Exception{
    new Thread(){
    public void run(){
    while(true){
    System.out.println(new Date().toLocaleString());
    try{Thread.sleep(1000);
    }catch(Exception e){}
    }
    }
    }.start();
    }
    }打印结果:我想只显示一条,怎么做?
    2004-6-13 22:24:41
    2004-6-13 22:24:42
    2004-6-13 22:24:43
    2004-6-13 22:24:44
    2004-6-13 22:24:45
    2004-6-13 22:24:46