📄 join.java
字号:
class CustomThread extends Thread
{
CustomThread(String name)
{
super(name);
start();
}
public void run()
{
try {
for(int loop_index = 0; loop_index < 4; loop_index++) {
System.out.println((Thread.currentThread()).getName()
+ " thread here...");
Thread.sleep(1000);
}
} catch (InterruptedException e) {}
System.out.println((Thread.currentThread()).getName() + " ending.");
}
}
class join
{
public static void main(String args[])
{
CustomThread thread1 = new CustomThread("first");
CustomThread thread2 = new CustomThread("second");
CustomThread thread3 = new CustomThread("third");
CustomThread thread4 = new CustomThread("fourth");
try {
thread1.join();
thread2.join();
thread3.join();
thread3.join();
} catch (InterruptedException e) {}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -