请问如何用多线程显示当前的时间!
请各位写出来!
请各位写出来!
解决方案 »
- JAVA 构造函数
- 急!为什么键盘监听有的时候可以,有的时候失灵?
- 为什么命令行的字符串(String)参数,无论有无引号,输出效果等同?
- 某公司java笔试题求解
- ****html页面中不能显示applet小程序,不知道为什么?***
- 请问如何判定一个Connection已经超时了?
- 这些代码有问题吗?提示resolve constructor player
- 国内站点哪有下载j2se1.4的document?
- 送分题
- java开发数据库,一般是用JDBC-ODBC桥,还是JDBC驱动程序连接数据库呢?
- 怎么把一个非static变量的值赋给static变量,在线等!
- 几个疑惑的问题?顶者均有分
Thread(1000)
Date dt = new Date();
lbltime .setText("当前日期:" + dt.toGMTString());
Thread.sleep(1000);
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