线程休眠
package com.li.thread_state;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TestThreadSleep {
public static void main(String[] args) {
while (true) {
try {
Thread.sleep(1000);
Date startDate = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
System.out.println(simpleDateFormat.format(startDate));
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public static void tenDown() throws InterruptedException {
int num = 10;
while (true) {
Thread.sleep(1000);
System.out.println(num--);
if (num<0){
break;
}
}
}
}