Quick revision
The short answer
Each step answered a cost the previous design made everyone pay. Hashtable and Vector in 1.0 locked every call, even in single-threaded code, so 1.2 separated thread safety from the data structure with unsynchronized collections plus opt-in synchronized wrappers. Wrappers still serialized all access and left compound actions unsafe, so Java 5 adopted Doug Lea's concurrency library with collections designed for concurrency and atomic compound operations. Java 8 rewrote ConcurrentHashMap again because multicore hardware and contention patterns had changed. The lesson for platform decisions is to keep interfaces stable while letting implementations change, and not to lock a design to today's hardware.
What to remember
In this answer, we followed Java's shared collections from synchronized Hashtable and Vector in 1.0, through unsynchronized collections with opt-in wrappers in 1.2, to Doug Lea's java.util.concurrent in Java 5 with collections built for concurrency and atomic compound operations, and the Java 8 lock-per-bin rewrite of ConcurrentHashMap for multicore machines. Each change answered a cost the previous design imposed under new hardware and workloads. The platform lessons are to keep interfaces stable while allowing implementations to change, to record and revisit the hardware assumptions behind a design, and to make safety cheap by default and explicit where it costs.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Each step answered a cost the previous design made everyone pay. Hashtable and Vector in 1.0 locked every call, even in single-threaded code, so 1.2 separated thread safety from the data structure with unsynchronized collections plus opt-in synchronized wrappers. Wrappers still serialized all access and left compound actions unsafe, so Java 5 adopted Doug Lea's concurrency library with collections designed for concurrency and atomic compound operations. Java 8 rewrote ConcurrentHashMap again because multicore hardware and contention patterns had changed. The lesson for platform decisions is to keep interfaces stable while letting implementations change, and not to lock a design to today's hardware.
Why this question is asked
Java's collections have been redesigned three times in public, each time while keeping old code running. That makes them one of the best long-term case studies in platform engineering available to any of us: we can see what each design assumed about programs and hardware, how those assumptions failed, and how the platform changed course without breaking its users. Interviewers ask this at the most senior level because the history itself is not the point; the point is whether the candidate can draw from it lessons that apply to their own organisation's platforms. In this answer, we will walk through the four stages, explain what drove each change, and then turn the pattern into principles for platform decisions.
1Java 1.0: Thread Safety Built Into Every Call
Java was designed in the mid-1990s with threads in the language from day one, and the original collections reflected that. Vector and Hashtable declared their public methods synchronized, so every call acquired the object's monitor, the lock built into every Java object. The idea was reasonable: make the common containers safe, so programmers cannot corrupt them by accident.
The cost appeared quickly. Most collections are used by a single thread, yet every call paid for locking. On the JVMs of the time, before optimizations like biased locking and lock elision existed, that cost was significant. And the safety was shallower than it looked, because sequences of calls, such as checking for a key and then putting it, were still not atomic.
2Java 1.2: Separate Safety From the Data Structure
The collections framework in Java 1.2, designed by Joshua Bloch, introduced interfaces such as List, Set and Map with unsynchronized implementations like ArrayList and HashMap. Thread safety became an optional layer: Collections.synchronizedList and synchronizedMap wrap any collection in a decorator whose methods lock. Single-threaded code stopped paying for locks it did not need, and Vector and Hashtable were retrofitted to implement the new interfaces so old code kept working.
But the wrappers had the same two limits as their predecessors. Every operation took one lock, so as soon as several threads shared a collection, they serialized. And compound actions such as check-then-act, or iteration, still required callers to lock the wrapper manually, which many forgot.
| Release | Design | What drove the next change |
|---|---|---|
| 1.0 (1996) | Vector, Hashtable: every method synchronized | Locking cost in single-threaded code |
| 1.2 (1998) | Unsynchronized collections + wrappers | One lock serializes; compound actions unsafe |
| 5 (2004) | java.util.concurrent, segmented ConcurrentHashMap | Many cores; segments and size too coarse |
| 8 (2014) | ConcurrentHashMap: CAS and lock per bin | Still evolving with hardware and workloads |
3Java 5: Collections Designed for Concurrency
By the early 2000s, servers had several CPUs and Java was running large multithreaded server applications. Doug Lea had for years maintained a library of concurrency utilities, and through JSR 166 it became java.util.concurrent in Java 5. Instead of adding a lock around existing structures, these collections were designed for concurrent access: ConcurrentHashMap split the table into segments, 16 by default, each with its own lock, so threads working on different segments did not block each other, and reads mostly avoided locking. CopyOnWriteArrayList, ConcurrentLinkedQueue and the blocking queues arrived at the same time.
Just as important, the ConcurrentMap interface added atomic compound operations such as putIfAbsent, replace and remove(key, value). The check-then-act race that wrappers left to callers was now handled by the map in a single call. Alongside came a new memory model in JSR 133, which gave volatile and final the precise meanings these structures depend on.
4Java 8: Rewriting ConcurrentHashMap for New Hardware
A decade later, machines had dozens of cores, and the segment design showed its age. Sixteen segments meant at most sixteen concurrent writers by default, a fixed choice made at construction. Each segment carried its own lock and table overhead, and operations such as size() had to coordinate across segments. Java 8 replaced it entirely: the table became an array of bins, an insert into an empty bin used a single compare-and-set, an update to an occupied bin locked only that bin's first node, counting moved to LongAdder-style cells, resizing became cooperative across threads, and long bins turned into trees. The same release added compute, computeIfAbsent and merge, plus parallel bulk operations.
Notice what did not change: the Map and ConcurrentMap interfaces. Code written against ConcurrentHashMap in 2004 compiled and ran on Java 8 and simply became faster. The concurrencyLevel constructor parameter survived as a sizing hint, kept for compatibility even though segments no longer existed.
5The Lessons for Platform Decisions
The first lesson is to keep interfaces stable and implementations replaceable. Java could rebuild ConcurrentHashMap twice because users depended on Map and ConcurrentMap, not on segments or bins. In our platforms, that means designing service APIs, library interfaces and configuration contracts so the implementation behind them can be swapped, and resisting the temptation to expose internals for short-term convenience.
The second lesson is that designs encode the hardware and workload of their time. Synchronized-everything assumed one CPU and simple programs; segments assumed a handful of cores. Each was sensible when made and became a bottleneck later. So we should record the assumptions behind a platform decision, such as expected core counts, traffic, data sizes or a cloud pricing model, and revisit them when those assumptions change, rather than treating the decision as permanent.
The third lesson is that safety should be cheap in the common case and explicit where it costs something. Java 1.2's opt-in safety and Java 5's atomic operations both moved responsibility to where it belongs. In an organisation, that is the difference between a platform that forces a heavy mechanism on everyone and one that offers a safe default with an opt-in for the hard cases.
- Callerscode written against Map and
ConcurrentMapsince 2004 - InterfaceMap,
ConcurrentMap: unchanged contract - Implementationsegments in Java 5, bins with CAS in Java 8
- Hardwarea few CPUs then, dozens of cores now
4 layers, from the top down. Step through them one at a time.
6Follow-up questions
Why were Vector and Hashtable never removed?
Because removing them would break a huge amount of existing code and APIs, such as java.util.Properties, which extends Hashtable. Java's strong compatibility promise means legacy classes are discouraged rather than deleted, which is itself a platform lesson about the cost of breaking users.
Why did the wrappers not make compound actions atomic?
A wrapper only sees individual method calls; it cannot know which calls the caller meant as a unit. Atomic compound behaviour needs new operations that express the whole intent, like putIfAbsent or merge, which is what Java 5 and Java 8 added.
How would you apply the hardware lesson today?
Many current designs assume a fixed thread pool per request, a particular memory-to-core ratio, or a single region. Virtual threads, ARM servers and multi-region deployments change those assumptions, so platform decisions made five years ago, such as pool sizes or caching layers, deserve a fresh look with current measurements.
7Conclusion
In this answer, we followed Java's shared collections from synchronized Hashtable and Vector in 1.0, through unsynchronized collections with opt-in wrappers in 1.2, to Doug Lea's java.util.concurrent in Java 5 with collections built for concurrency and atomic compound operations, and the Java 8 lock-per-bin rewrite of ConcurrentHashMap for multicore machines. Each change answered a cost the previous design imposed under new hardware and workloads. The platform lessons are to keep interfaces stable while allowing implementations to change, to record and revisit the hardware assumptions behind a design, and to make safety cheap by default and explicit where it costs.
Open with
Each step was driven by a cost the previous design imposed. In Java 1.0, Vector and Hashtable synchronized every method, so even single-threaded code paid for locking, and compound actions still weren't safe.
Then, if they want more
Java 1.2's collections framework separated the two concerns: ArrayList and HashMap are unsynchronized, and if you need safety you opt in with Collections.synchronized wrappers. But the wrappers still use one lock for everything, so shared collections serialize under load, and check-then-act or iteration still need manual locking.
Java 5 brought in Doug Lea's concurrency library as java.util.concurrent, with collections designed for concurrency, like the segmented ConcurrentHashMap, CopyOnWriteArrayList and the blocking queues, and atomic compound operations such as putIfAbsent, plus a proper memory model.
Then Java 8 rewrote ConcurrentHashMap again, because with dozens of cores the fixed sixteen segments were too coarse; it moved to compare-and-set on empty bins and locking a single bin, with tree bins and cooperative resizing. The key point is that the interfaces, Map and ConcurrentMap, never changed, so code from 2004 just got faster.
The lessons I take for platform decisions are: keep interfaces stable and implementations replaceable, so you can rebuild the inside without migrating every user; write down the hardware and workload assumptions behind a design and revisit them when they change, rather than locking the design to today's machines; and make safety cheap by default, with explicit options where it costs more.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 5, Java 8
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Java went from synchronized Hashtable and Vector (1.0), to unsynchronized collections...": https://scrivio-interview-library.netlify.app/java/concurrent-collections/2a2ac1a7eb/