亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

interruped(線程的中斷)

interruped(線程的中斷)

woshi123w 2016-07-02 23:38:18
public class ceshi extends Thread{?public void run(){? ?while(!this.isInterrupted()){ ? System.out.println("線程正在執行中"); ? long time=System.currentTimeMillis(); ?while((System.currentTimeMillis()-time)<1000){ ??}? ?}?}?public static void main(String[] args) throws InterruptedException { ceshi xu=new ceshi(); System.out.println("線程開始啟動1");//main是主線程 xu.start();? Thread.sleep(3000);? System.out.println("線程正在停止中");? ? xu.interrupted();? ? Thread.sleep(3000);? ? System.out.println("線程已經終止");?}}為什么停止不了?。。?
查看完整描述

1 回答

?
redstonesl

TA貢獻55條經驗 獲得超12個贊

用 布爾值在run中控制停止,朋友

查看完整回答
1 反對 回復 2016-07-03
  • 1 回答
  • 0 關注
  • 1847 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號