package cn.thread2;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* sleep实现数羊,一秒数一只
* @author Chill Lyn
*
*/
public class TestSleep {
public static void main(String[] args) throws InterruptedException {
int i = 1;
while (true) {
Date time = new Date(System.currentTimeMillis());
System.out.println(new SimpleDateFormat("yy-MM-dd hh:mm:ss").format(time));
System.out.println(i++ + "只羊");
Thread.sleep(1000);
}
}
}
Java_多线程_ sleep实现数羊,一秒数一只,快乐睡眠每一天
最新推荐文章于 2022-02-23 14:07:53 发布