📄 sleeptest.java
字号:
public class SleepTest implements Runnable
{
public static void main(String[] aa)
{
Thread t = Thread.currentThread();
t.setName("My Thread");
System.out.println("The runnong thread:"+t);
try
{
for(int i=0;i<5;i++)
{
System.out.println("Sleep time"+i);
Thread.sleep(1000);
}
System.out.println("Hello! "+t.getName());
}
catch(InterruptedException e)
{
System.out.println("The thread was wrong");
}
}
}
//sleep()示例
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -