第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

個人練習:正確使用interrupt()停止進程

package?com.imooc.concurrent.base;

public?class?InterruptWayStopThread?extends?Thread{
	
	volatile?boolean?stop?=?false;
	public?static?void?main(String[]?args)?{
		InterruptWayStopThread?thread?=?new?InterruptWayStopThread();
		System.out.println("Starting?thread...");
		thread.start();
		try?{
			Thread.sleep(3000);
		}?catch?(InterruptedException?e)?{
			//?TODO?Auto-generated?catch?block
			e.printStackTrace();
		}
		System.out.println("Interrupting?thread...");
		thread.stop?=?true;????????//線程要是處于阻塞模式,將不會檢查此處的變量
		thread.interrupt();
		try?{
			Thread.sleep(3000);
		}?catch?(InterruptedException?e)?{
			e.printStackTrace();
		}
		System.out.println("Stopping?appplication...");		
	}
	
	@Override
	public?void?run()?{
		while(!stop){
			System.out.println("Thread?is?running...");
			try?{
				Thread.sleep(1000);
			}?catch?(InterruptedException?e)?{
				System.out.println("Thread?interrupted..");
			}
		}
		System.out.println("Thread?exiting?under?requestion...");
				
	}

}


正在回答

3 回答

哈哈,微笑不語

0 回復(fù) 有任何疑惑可以回復(fù)我~

? 哎呦,這個還是用了標志位設(shè)置的。。。

0 回復(fù) 有任何疑惑可以回復(fù)我~
thread.stop?=?true;????????//線程要是處于阻塞模式,將不會檢查此處的變量

這句是什么意思???是字面意思吧?就是thread在sleep的時候不去取stop的值?

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

個人練習:正確使用interrupt()停止進程

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號