美文网首页
5.2、线程休眠

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