【发布时间】:2012-11-03 18:16:21
【问题描述】:
我对@987654321@ 代码中的 sn-p 感到困惑:
void stopTestThread() {
// thread should cooperatively shutdown on the next iteration, because field is now null
Thread testThread = m_logTestThread;
m_logTestThread = null;
if (testThread != null) {
testThread.interrupt();
try {testThread.join();} catch (InterruptedException e) {}
}
}
是不是说 testThread 和 m_logTestThread 是不同的实例,但指向内存中的同一个对象,所以它们是同一个线程?
如果有,if (testThread != null) 的目的是什么?
【问题讨论】:
标签: java multithreading