Java offers synchronization at several levels of granularity and control, ranging from the built-in synchronized keyword to explicit locks and higher-level coordination utilities in the java.util.concurrent package.
A producer-consumer pipeline might use a BlockingQueue to hand off work between threads without any manual synchronized blocks, while a resource pool limiting concurrent database connections to ten might use a Semaphore(10) to cap simultaneous access.
Semaphore semaphore = new Semaphore(10);
public void useResource() throws InterruptedException {
semaphore.acquire();
try {
// access limited resource
} finally {
semaphore.release();
}
}A concise interview answer is
There are several layers available: the synchronized keyword and volatile for basic cases, explicit locks like ReentrantLock for more control, Semaphore for bounding concurrent access, CountDownLatch or CyclicBarrier for coordinating groups of threads, and concurrent collections that are thread-safe by design so you don't need to synchronize around them at all.
Last updated: 16 July 2026
Previous question: How do you get a thread dump in Java?
Next question: What is the difference between a synchronized method and a synchronized block?