backgroundThread.join(); //“等待该线程终止”
backgroundThread = null;
Después de la modificación
backgroundThread.quit();
backgroundThread.interrupt();
backgroundThread = null;
private Runnable periodicDetect =
new Runnable() {
@Override
public void run() {
synchronized (lock) {
if (runDetector) {
detectFace();
}
if(backgroundHandler!=null){ //添加验证 防止内存泄漏报错
if(backgroundThread!=null)//添加验证 防止内存泄漏报错
backgroundHandler.post(periodicDetect);
}
}
}
};