标签:time() current format oid ring out system 输出 线程
//sleep模拟网络延迟:public class hh implements Runnable {
public static void main(String[]args) throws InterruptedException
{
Date date=new Date(System.currentTimeMillis()+1000*10);//当前时间加10秒
long endTime=date.getTime();
while(true)
{
System.out.println(new SimpleDateFormat("mm:ss").format(date));//以分:秒的形式输出
Thread.sleep(1000);
date=new Date(date.getTime()-1000);
if(endTime-1000*10>date.getTime())
{
break;
}
}
}
public static void test() throws InterruptedException
{
int num=10;
while(true)
{
Thread.sleep(1000);
System.out.println(num--);
}
}
}
标签:time() current format oid ring out system 输出 线程
原文地址:https://blog.51cto.com/14437184/2427791