线程休眠 模拟倒计时

package com.ma.state;

import java.nio.channels.FileLockInterruptionException;

public class TestSleep2 {
    public static void main(String[] args) {
        try {
            TenDown();
        } 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;

            }
        }
    }
}
上一篇:传统生产者消费者问题、防止虚假唤醒


下一篇:Java 8种线程顺序执行方法(main)