关于Android 线程的销毁问题

2014-11-24 10:21:55 · 作者: · 浏览: 0


main_thread=new Thread(new Runnable() {


public void run() {


while (time > 0&&!cancle) {


System.out.println(time);


try {


Thread.sleep(1000);


mHandler.post(new Runnable() {


public void run() {


String text = getString(R.string.LeftTime);


message.setText(text + time);



}


}


}


});




time--;



if (time <= 0) {



Intent intent = new Intent();


intent.setClass(MapActivity.this,


RateActivity.class);


finish();



startActivity(intent);


}


if(cancle)


{


return; //结束线程


}


} catch (InterruptedException e) {


// TODO Auto-generated catch block


e.printStackTrace();


}


}



}



private void sleep(int i) throws InterruptedException {



Thread.sleep(i);


}


});


main_thread.start();