sleep
image.pngpackage com.example.demo.thread;
/**
* @projectName: demo
* @package: com.example.demo.thread
* @className: TestSlepp
* @author:
* @description: 模拟倒计时
* @date: 2021/11/26 17:43
*/
public class TestSleep {
public static void main(String[] args) throws InterruptedException {
TestSleep testSleep = new TestSleep();
testSleep.tenDown();
}
void tenDown() throws InterruptedException {
int num = 10;
while (num > 0) {
Thread.sleep(1000);
System.out.println(num);
num--;
}
}
}
网友评论