What is the difference between a synchronized method and a synchronized block?

A synchronized method locks an entire method body using an implicit lock — the instance for a non-static method or the Class object for a static one — while a synchronized block lets you lock only a specific, smaller section of code on a lock object you choose explicitly.

Key Points

Example

If only a small part of a method actually touches shared state, wrapping just that portion in synchronized(lockObject) { ... } instead of marking the whole method synchronized lets unrelated, non-critical parts of the method run without contending for the lock.

// Synchronized method - locks the whole method on 'this'
public synchronized void updateAll() {
    // entire method is the critical section
}

// Synchronized block - locks only the critical section
public void updatePartial() {
    // non-critical setup work here
    synchronized (this) {
        // only this part is the critical section
    }
}

Interview Tip

A concise interview answer is

A synchronized method locks the whole method body on an implicit lock — the instance or the class for static methods — while a synchronized block lets you scope the lock to just the critical lines and choose the lock object yourself. Blocks are generally preferred when only part of a method needs protection, since they reduce how long the lock is held.

Last updated: 11 November 2026

Previous question: What are the different ways to achieve synchronization in Java?

More Concurrency and Multithreading interview questions

All Concurrency and Multithreading questions