看板 java 關於我們 聯絡資訊
Hi, 我寫多執行緒程式遇到 IllegalMonitorStateException, 為了查明發生的原因, 我查了一下文件: http://tinyurl.com/2h93vm 上面的說明寫道: Thrown to indicate that a thread has attempted to wait on an object's monitor or to notify other threads waiting on an object's monitor without owning the specified monitor. 請問「擁有該物件的 monitor」(owning the specified monitor) 是什麼意思? 謝謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.119.164.218
H45:有沒有寫 synchronized (...) { ... } ? 12/18 23:25
eliang:ok 我知道為什麼了 3Q 12/19 14:31
H45:這個不好解釋,請問你能不能分享一下為什麼會發生嗎... 12/19 17:53
eliang:就如你所說, obj.wait() 和 obj.notify() 外面一定要包 12/19 20:55
eliang:synchronized(obj) { ... } 12/19 20:56
H45:ok, 感謝您喚起我的回憶 12/19 23:27