Top 10 Java Multithreading Interview Questions Every Fresher Should Know
Top 10 Java Multithreading Interview Questions Every Fresher Should Know Work through these 10 questions out loud. Open any question for the full model answer, the trap to avoid, and the follow-up a panel usually asks.
volatile vs synchronized — when to use each?
volatile for single-writer flags (shutdown, initialized) where no read-modify-write. synchronized or java.util.concurrent locks when multiple threads update shared state. For...
Why is ThreadLocal problematic with virtual threads?
Libraries storing per-request state in ThreadLocal allocate one entry per virtual thread — catastrophic memory with 100k concurrent requests. Prefer ScopedValue for request...
Explain the happens-before relationship in the Java Memory Model.
Thread A writes x=1 without sync; Thread B reads x may see 0 forever. volatile x or synchronized block creates happens-before. Classic DCL singleton needs volatile instance...
HashMap vs ConcurrentHashMap — when and why?
HashMap for single-threaded or external synchronization. ConcurrentHashMap for shared concurrent maps — finer-grained locking than Hashtable. Cannot store null keys/values in...
Explain immutability and why String is immutable.
Immutable objects cannot change after build — thread-safe without synchronization. String immutability allows intern pool, caching hashCode, and security when used as...
How does Stream API parallel stream work?
parallelStream() splits work across common pool threads. Good for CPU-heavy map on large in-memory collections. Bad for small lists, IO inside stream, or ordered stateful...
What is an ExecutorService and why use it?
Instead of new Thread per task, submit Runnable to fixed pool sized to CPU/IO profile. Handle Future results and exceptions. On shutdown hook call shutdown() and...
What are virtual threads in Java 21 and when should you use them?
Virtual threads excel when code blocks on IO — HTTP clients, JDBC, file reads — allowing one platform thread to serve thousands of concurrent requests. For CPU-heavy parallel...
How do CompletableFuture and virtual threads compare for concurrency?
Use virtual threads when business logic is naturally blocking — call DB, call HTTP, return. Use CompletableFuture when composing multiple independent async results with...
When should you use CopyOnWriteArrayList?
Use for subscriber lists in pub/sub where adds are rare and iteration is constant. Avoid for high-frequency add/remove — use ConcurrentLinkedQueue or synchronized collections....
Java Multithreading Interview Questions and Answers · Top 50 Java Multithreading Interview Questions and Answers (2026 Edition) · Top 40 Java Multithreading Interview Questions | Must-Prepare before interview. · Java Multithreading Interview Questions Every Fresher Must Know
All interview question lists · Interview guides · Home · Support the platform