摘要:
Java 之前有个api函数可以直接关闭线程, stop(), 后来, 取消了. 其替代的方式主要有两种:1. 自己加入一个成员变量, 我们在程序的循环里面, 轮流的去检查这个变量, 变量变化时,就会退出这个线程. 代码示例如下packagecom.test;publicclassStopThreadextendsThread{privateboolean_run=true;publicvoidstopThread(booleanrun){this._run=!run;}@Overridepublicvoidrun(){while(_run){/////数据处理///}//super.run( 阅读全文