mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
25 lines
790 B
HTML
25 lines
790 B
HTML
<html>
|
|
<body>
|
|
Reports calls to <code>wait()</code>, <code>notify()</code>, and <code>notifyAll()</code>
|
|
that are not made inside a corresponding synchronized statement or synchronized method.
|
|
<p>
|
|
Calling these methods on an object
|
|
without holding a lock on that object causes <code>IllegalMonitorStateException</code>.
|
|
Such a construct is not necessarily an error, as the necessary lock may be acquired before
|
|
the containing method is called, but it's worth looking at.
|
|
</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
class Sync {
|
|
private final Object lock = new Object();
|
|
|
|
void test() throws InterruptedException {
|
|
synchronized (this) {
|
|
lock.wait(); // 'lock.wait()' is not synchronized on 'lock'
|
|
}
|
|
}
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html> |