0
public class MyClass extends Thread{
public void run() {
try {
while(!Thread.currentThread().isInterrupted()) {
// ...
}
} catch (InterruptedException consumed)
/* Allow thread to exit */
}
}
public void cancel() { interrupt(); }
//etc.
}
因为某种原因,在解构对象之前我应该总是调用cancel(),还是不应该担心?如果对象不再被引用,那么对象的“线程”扩展线程会发生什么?
定义_deconstructing_。 – 2014-08-30 08:48:41
如果一个线程正在运行,它可以通过GC访问。我不明白你想问什么问题。 – tmyklebu 2014-08-30 08:50:03
解构:摆脱对象的引用... – 2014-08-30 08:51:26