mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-28 04:37:32 +07:00
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
23 lines
591 B
HTML
23 lines
591 B
HTML
<html>
|
|
<body>
|
|
Reports calls to <code>wait()</code> methods that may occur while the current thread is holding two locks.
|
|
<p>
|
|
Since calling <code>wait()</code> only releases one lock on its target,
|
|
waiting with two locks held can easily lead to a deadlock.
|
|
</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
synchronized (lockA) {
|
|
synchronized (lockB) {
|
|
lockB.wait(); //warning
|
|
//thread A is stuck here holding lockA
|
|
}
|
|
}
|
|
|
|
synchronized (lockA) { //thread B can't enter the block and release thread A
|
|
lockB.notify();
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html> |