Inspectopedia Help

Empty 'synchronized' statement

Reports synchronized statements with empty bodies.

Empty synchronized statements are sometimes used to wait for other threads to release a particular resource. However, there is no guarantee that the same resource won't be acquired again right after the empty synchronized statement finishes. For proper synchronization, the resource should be utilized inside the synchronized block.

Also, an empty synchronized block may appear after a refactoring when redundant code was removed. In this case, the synchronized block itself will be redundant and should be removed as well.


synchronized(lock) {}

A quick-fix is suggested to remove the empty synchronized statement.

This inspection is disabled in JSP files.

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3


Java, 233.SNAPSHOT

Last modified: 13 July 2023