我看到這一點:這樣好嗎?同步(線程),那麼線程= NULL在同步塊
// thread is a member of this class
synchronized(this.thread)
{
this.thread.running = false;
this.thread.notifyAll(); // Wake up anything that was .waiting() on
// the thread
this.thread = null; // kill this thread reference.
// can you do that in a synchronized block?
}
它是確定設置thread=null
,同時仍保持對鎖嗎?
我發現這個塊有點BB代碼。
是否有任何理由你沒有使用Thread.interrupt(),因爲這是由底層庫支持的? – 2010-11-19 17:51:26