Back to Intellij Community

SynchronizeOnLock

java/java-impl/resources/inspectionDescriptions/SynchronizeOnLock.html

2025.3-rc-2348 B
Original Source

Reports synchronized blocks that lock on an instance of java.util.concurrent.locks.Lock. Such synchronization is almost certainly unintended, and appropriate versions of .lock() and .unlock() should be used instead.

Example:

final ReentrantLock lock = new ReentrantLock();

  public void foo() {
    synchronized (lock) {}
  }