分类: Android平台
2015-06-24 17:12:14
在android中开启的线程用Thread.stop()来关闭是不会真正关闭的,当我们再次start线程的时候,会产生异常:Thread is already started.
针对这个问题可以在线程的run方法里,加一个判断标志。例如:
class TestThread extends Thread{
public void run(){
while(isTrue){
//做你要做的事。
}
}
}
mTestThread.interrupt();
mTestThread=null;