deprecatedstop.java

来自「java多线程编程实例_Source」· Java 代码 · 共 34 行

JAVA
34
字号
public class DeprecatedStop extends Object implements Runnable {

	public void run() {
		int count = 0;

		while ( true ) {
			System.out.println("Running ... count=" + count);
			count++;

			try {
				Thread.sleep(300);
			} catch ( InterruptedException x ) {
				// ignore
			}
		}
	}


	public static void main(String[] args) {
		DeprecatedStop ds = new DeprecatedStop();
		Thread t = new Thread(ds);
		t.start();

		try {
			Thread.sleep(2000);
		} catch ( InterruptedException x ) {
			// ignore
		}

		// Abruptly stop the other thread in its tracks!
		t.stop();
	}
}

⌨️ 快捷键说明

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