testfirstthread.java

来自「国外的数据结构与算法分析用书」· Java 代码 · 共 21 行

JAVA
21
字号
/**	A simple class to test class FirstRunnable.  It creates three instances of
	FirstThread, and lets them run for half a second, then stops their running
	so they can display their result. */
public class TestFirstThread
{
	public static void main(String[] args) throws InterruptedException
	{
		FirstThread f1 = new FirstThread();
		FirstThread f2 = new FirstThread();
		FirstThread f3 = new FirstThread();

		f1.start();
		f2.start();
		f3.start();

		Thread.sleep(500); // can throw an exception
		FirstThread.running = false;
		Thread.sleep(2000); // can throw an exception
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?