📄 waitfordeath.java
字号:
// Chapter 7, Listing 5
public class WaitForDeath extends Thread
{
// Run method is executed when thread first started
public void run()
{
System.out.println ("This thread feels a little ill....");
// Sleep for five seconds
try
{
Thread.sleep(5000);
}
catch (InterruptedException ie) {}
}
// Main method to create and start threads
public static void main(String args[]) throws java.lang.InterruptedException
{
// Create and start dying thread
Thread dying = new WaitForDeath();
dying.start();
// Prompt user and wait for input
System.out.println ("Waiting for thread death");
// Wait till death
dying.join();
System.out.println ("Thread has died");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -