/**
需求
波动拳第 1 发
波动拳第 2 发
波动拳第 3 发
开始为时5秒的充能
波动拳第 1 发
波动拳第 2 发
波动拳第 3 发
开始为时5秒的充能
波动拳第 1 发
波动拳第 2 发
波动拳第 3 发
开始为时5秒的充能
*/
public class Prastic1 {
public static void main(String[] args) {
Thread t1 = new Thread() {
@Override
public void run() {
int sec = 0;
while (true) {
try {
Thread.sleep(1000);
sec++;
} catch (InterruptedException e) {
e.printStackTrace();
}
if (sec > 3) {
sec = 1;
System.out.println("开始为时5秒的充能");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.printf("波动拳第 %d 发 %n", sec);
}
}
};
t1.start();
}
}
點擊查看更多內容
為 TA 點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦