What is a synchronized collection, and how does it differ from a concurrent collection?

A synchronized collection is a regular collection wrapped so that every method call is guarded by a single lock, while a concurrent collection from java.util.concurrent is purpose-built for multithreaded access using finer-grained or lock-free techniques for much better throughput.

Key Points: • Collections.synchronizedList()/synchronizedMap() wrap an existing collection, serializing all access behind one lock — only one thread can touch it at a time. • Iterating a synchronized collection still requires manual external synchronization to avoid ConcurrentModificationException. • Concurrent collections like ConcurrentHashMap and CopyOnWriteArrayList allow multiple threads to read and often write simultaneously without a single global lock. • Concurrent collections generally provide weakly-consistent iterators that don't throw ConcurrentModificationException, reflecting the collection's state at some point during iteration rather than a hard snapshot. • Under real contention, concurrent collections dramatically outperform synchronized wrappers because they avoid a single choke-point lock.

Example: Wrapping an ArrayList with Collections.synchronizedList() to share it across threads still serializes every add() and get() through one lock, whereas swapping in a CopyOnWriteArrayList lets reads proceed lock-free entirely, which is ideal for a read-heavy, write-rare listener list.

Code Example:

List<String> syncList = Collections.synchronizedList(new ArrayList<>());
Map<String, Integer> concurrentMap = new ConcurrentHashMap<>();

Interview Tip: A concise interview answer is:

"A synchronized collection wraps a normal collection with a single lock around every method, so only one thread accesses it at a time and iteration still needs manual synchronization. A concurrent collection like ConcurrentHashMap is designed for multithreaded access from the ground up, using finer-grained locking or lock-free algorithms for much better concurrent throughput."