作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
每次我创建新线程时,它都会被添加到主线程组中,即使我将线程清零,它仍然存在于主线程组中,导致内存泄漏。请帮忙
已更新
public void surfaceDestroyed(SurfaceHolder holder) {
Log.d("mThread", "Surface Destroyed Called");
getHolder().removeCallback(this);
boolean retry = true;
_thread.setRunning(false);
while (retry) {
try {
Log.d("mThread", "b4 Interrupted");
_thread.interrupt();
Log.d("mThread", "b4 thread group Interrupted");
_thread.getThreadGroup().interrupt();
Log.d("mThread", "b4 join");
_thread.join();
retry = false;
} catch (InterruptedException e) {
Log.d("mThread", "Interrupted");
Thread.currentThread().interrupt();
_thread.getThreadGroup().list();
_thread = null;//======>here nulling thread
break;
}
}
}
最佳答案
问题不在于加入了线程组。已终止的线程将始终(最终)从线程组中删除。
如果应用程序正在泄漏内存,那么您的代码中就有错误。你找错人了。
关于java - 如何从线程组中删除线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6304985/
我是一名优秀的程序员,十分优秀!