📄 testthread.java
字号:
import junit.framework.*;
class DelayedHello implements Runnable {
private int count;
private Thread worker;
public DelayedHello(int count) {
this.count = count;
worker = new Thread(this);
worker.start();
}
public void run() {
try {
Thread.sleep(count);
System.out.println("Delayed Hello World");
} catch(InterruptedException e) {
e.printStackTrace();
}
}
}
public class TestThread extends TestCase {
private Runnable runnable;
public void testExampleThread() throws Throwable {
System.out.println("Hello, World"); //1
runnable = new DelayedHello(500); //2
System.out.println("Goodbye, World"); //3
}
public static void main (String[] args) {
junit.textui.TestRunner.run(TestThread.class);
}
public static Test suite() {
return new TestSuite(TestThread.class);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -