📄 testjoin2.java
字号:
/* * TestJoin2.java * * Created on September 25, 2002, 12:08 PM */package ch18;/** * * @author Stephen Potts */public class TestJoin2 extends Thread{ /** Creates a new instance of TestJoin2 */ public TestJoin2() { } public void run() { try { for ( int i=0; i<5; i++) { System.out.println("running the first loop " + i); } Thread.sleep(5000); for ( int i=6; i<10; i++) { System.out.println("running the second loop" + i); } }catch (InterruptedException ie) { System.out.println("Sleep interrupted in run()"); } } public static void main(String[] args) { try { TestJoin2 t2 = new TestJoin2(); Thread t = new Thread(t2); t.start(); t.join(3000); for ( int i=11; i<15; i++) { System.out.println("running the third loop" + i); } }catch (InterruptedException ie) { System.out.println("Join interrupted in run()"); } System.out.println("Exiting from Main"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -