今天写代码遇到一个异常java.lang.IllegalMonitorStateException,百度问题,搜索blog得知
JavaDoc上关于IllegalMonitorStateException的解释是:
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.
看起来有些晦涩难懂,比如object’s monitor。其实,在Object.notify()这个函数的JavaDoc中有相关的解释:
A thread becomes the owner of the object’s monitor in one of three ways:
1). By executing a synchronized instance method of that object.
2). By executing the body of a synchronized statement that synchronizes on the object.
3). For objects of type Class, by executing a synchronized static method of that class. ---------------------
作者:historyasamirror
来源:CSDN
原文:https://blog.csdn.net/historyasamirror/article/details/6709693
博主写代码时遇到java.lang.IllegalMonitorStateException异常,通过搜索得知JavaDoc对该异常的解释较晦涩,还提到在Object.notify()函数的JavaDoc中有关于线程成为对象监视器所有者的三种方式的相关解释。

276

被折叠的 条评论
为什么被折叠?



