Inspectopedia Help

Nested 'synchronized' statement

Reports nested synchronized statements. It is recommended to avoid nested synchronization if possible, because in some cases it may lead to a deadlock.

Example:

synchronized (lockA){ //thread 1 is waiting for lockB synchronized (lockB){ //warning } } ... synchronized (lockB) { //thread 2 is waiting for lockA synchronized (lockA) { //warning } }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023