悟空老师,我怎么能不使用sleep等方法情况下停止线程,不使用stop等
来源:5-5 中断信号
 
			LambertJiang
2020-07-19
public class StopTest implements Runnable{
	public static void main(String[] args) {
		Thread th = new Thread(new StopTest());
		th.start();
		try {
			Thread.sleep(10);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		th.interrupt();
	}
	@Override
	public void run() {
		for(int i=0 ; i<1000000 ; i++) {
			System.out.println(i);
		}
		
	}
}
写回答
	1回答
- 
				
				你把这章看完吧,讲的就是如何停止线程 012020-07-19
相似问题
