testsleep.java

来自「java2 primer plus一书源程序」· Java 代码 · 共 39 行

JAVA
39
字号
/* * TestSleep.java * * Created on September 25, 2002, 11:10 AM */package ch18;/** * * @author  Stephen Potts */public class TestSleep{        /** Creates a new instance of TestSleep */    public TestSleep()    {    }        public static void main(String[] args)    {        try        {        for (int i=0; i<5;i++)        {            System.out.println("The counter = " + i);            Thread.sleep(2000);        }        }catch (InterruptedException ie)        {            System.out.println("Sleep interrupted");        }        Thread t = Thread.currentThread();        System.out.println("The Thread name is " + t.getName());    }    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?