firstrunnable.java

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

JAVA
22
字号
/**	A simple class which demonstrates implementing interface Runnable.  The class
	simply increments an instance variable until a flag is turned off.
	The value of the instance variable is then displayed to the console. */
public class FirstRunnable implements Runnable
{
	int count = 0;
	static volatile boolean running = true;

	public FirstRunnable()
	{
		Thread t = new Thread(this);
		t.start();
	}

	public void run()
	{
		while (running)
			count++;
		System.out.println("count is: " + count);
	}
}

⌨️ 快捷键说明

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