????Thread.stop?? Thread.suspend?? Thread.resume ??Runtime.runFinalizersOnExit ??Щ?????????е??????????????????????????????????
????????????????????Ч??????????????ò?????????Щ??????
????1??????????????????????????
?????????run???????????????????????????
????2???????Щ?????????????????????С?
???????????????Щ????????????????????????????У?????????Щ?????????????£?????????Щ????
?????????????????????while(true)????????С?
??????:
@Override
publicvoid run() {
while(true){
someWork();
if(finished){
break;
}
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
/* TODO??????? catch ??
*
*/
e.printStackTrace();
}
}
}
?????????????while????????????????????????????????????????????????????break?????????????????????????????????????????????
????3??????InterruptedException ??????????ж???????
??????Щ?????????????????while(true)??????????????????????????е????????????????????????????????????÷?????з????????????????????????У??????????????????
?????????????????????interrupt?????????????InterruptedException????????????????е????????????????????????????л???????????????С?
?????磺
@Override
publicvoid run() {
while(true){
try {
// getSendMessages ??BlockingQueue??????take??????????????
responseMessage = this.getSendMessages().take();
} catch (InterruptedException e1) {
thrownew RuntimeException();
//????break;
}
someWork();
}
???????????Thread ???? ?????????? ????????????????????????thread?????interrupt() ??????????
????responseMessage = this.getSendMessages().take();
????????????в??????InterruptedException???????????????????????????????????????break??????????????????????