java程序编译出错,求help

gedechuanshuo 2011-04-26 10:16:37
我是菜鸟,我在试验多线程时编译程序时报错:找不到方法currentTimeMillis();
import java.util.*;
class TimePrint extends Thread
{
int pause;
String name;
public TimePrint(int pause,String name)
{
this.pause=pause;
this.name=name;
}
public void run()
{
while(true)
{
try
{
System.out.println("Thread"+name+":"+new Date(currentTimeMillis()));
Thread.sleep(pause);
}
catch(Exception e)
{
e.getMessage();
}
}

}
public static void main(String [] args)
{
Thread timePrinta=new TimePrint(1000,"a");
timePrinta.start();
Thread timePrintb=new TimePrint(3000,"b");
timePrintb.start();
}
}
...全文
126 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
BJ_黑夜 2011-04-27
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 shengpulong 的回复:]
System.out.println("Thread"+name+":"+new Date(currentTimeMillis()));中的currentTimeMillis()改为System.currentTimeMillis()是静态方法,需要类名调用
[/Quote]

恩 正解
lost_guy_in_scut 2011-04-27
  • 打赏
  • 举报
回复
System.currentTimeMillis()
wang_huanming 2011-04-27
  • 打赏
  • 举报
回复
new Date(System.currentTimeMillis())
andlyLiu2013 2011-04-27
  • 打赏
  • 举报
回复
对啊 是 系统System的静态方法吗 还得sys 输出

System.out.println("Thread"+name+":"+new Date(currentTimeMillis()));中的currentTimeMillis()改为System.currentTimeMillis()是静态方法,需要类名调用
shengpulong 2011-04-27
  • 打赏
  • 举报
回复
System.out.println("Thread"+name+":"+new Date(currentTimeMillis()));中的currentTimeMillis()改为System.currentTimeMillis()是静态方法,需要类名调用
chenshimin1234 2011-04-27
  • 打赏
  • 举报
回复
System.currentTimeMillis()
微风飘过 2011-04-26
  • 打赏
  • 举报
回复
把currentTimeMillis()改为System.currentTimeMillis(),currentTimeMillis()方法是静态方法,用类名引用,
xcblljlforever 2011-04-26
  • 打赏
  • 举报
回复
把currentTimeMillis()改为System.currentTimeMillis()
24K純帥 2011-04-26
  • 打赏
  • 举报
回复
System.currentTimeMillis()
西斗纪名 2011-04-26
  • 打赏
  • 举报
回复
把currentTimeMillis()改为System.currentTimeMillis()
mickysky 2011-04-26
  • 打赏
  • 举报
回复
System.currentTimeMillis()

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧