5.2、线程休眠
作者:
金石_832e | 来源:发表于
2021-12-01 18:40 被阅读0次
sleep
image.png
package 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--;
}
}
}
本文标题:5.2、线程休眠
本文链接:https://www.haomeiwen.com/subject/esdxxrtx.html
网友评论