Multithreading & Concurrency Interview Questions
Threads, synchronization, deadlocks, volatile, and the Executor Framework.
- 20Questions with answers
- 3Difficulty levels
Questions (20)
Browse beginner, intermediate, and advanced questions with answers — hide them when you want to self-test.
What is a thread in Java?
A thread is a lightweight unit of execution that allows concurrent execution of tasks within a process.
What is the difference between a process and a thread?
A process is an independent program in execution, while a thread is a smaller execution unit within a process that shares resources.
What are the ways to create a thread in Java?
A thread can be created by extending the Thread class or implementing the Runnable interface.
What is the difference between Thread and Runnable?
Thread is a class, while Runnable is an interface. Implementing Runnable allows a class to extend another class.
What is the thread lifecycle?
A thread moves through New, Runnable, Running, Blocked/Waiting, and Terminated states during execution.
What is synchronization?
Synchronization controls access to shared resources, ensuring that only one thread accesses critical code at a time.
Why is synchronization needed?
Synchronization prevents data inconsistency and race conditions when multiple threads access shared resources.
What is a deadlock?
A deadlock occurs when two or more threads wait indefinitely for resources held by each other.
How can deadlocks be avoided?
Deadlocks can be avoided through lock ordering, lock timeouts, minimizing nested locks, and using concurrent utilities.
What is a race condition?
A race condition occurs when multiple threads modify shared data simultaneously, producing unpredictable results.
What is the difference between sleep() and wait()?
sleep() pauses a thread for a specified time without releasing locks, while wait() releases the lock and waits for notification.
What is the difference between notify() and notifyAll()?
notify() wakes one waiting thread, whereas notifyAll() wakes all waiting threads.
What is the volatile keyword?
volatile ensures that variable updates are immediately visible to all threads and prevents caching inconsistencies.
What is a thread pool?
A thread pool is a collection of reusable worker threads that improves performance by reducing thread creation overhead.
What is the Executor Framework?
The Executor Framework provides a high-level API for managing and executing asynchronous tasks using thread pools.
Which Java language or JDK features are essential when discussing Multithreading & Concurrency?
Name concrete APIs (collections, concurrency, streams, annotations) tied to Multithreading & Concurrency. Interviewers want syntax-level clarity plus when you would reach for each feature in production.
How does exception handling typically work around Multithreading & Concurrency in Java?
Prefer specific checked/unchecked exceptions, wrap lower-level failures with context, and avoid empty catch blocks. For Multithreading & Concurrency, decide what is recoverable vs fatal to the request thread.
What unit-testing approach would you use for Multithreading & Concurrency?
JUnit 5 with Arrange-Act-Assert, Mockito for collaborators, and parameterized tests for edge cases. Keep Multithreading & Concurrency logic pure where possible so tests stay fast.
How do equals/hashCode or identity rules affect Multithreading & Concurrency?
Incorrect equals/hashCode break HashMap/HashSet behavior. If Multithreading & Concurrency stores objects in collections, explain the contract and mutability pitfalls.
What memory or GC concern should juniors watch with Multithreading & Concurrency?
Retain only needed references, prefer streaming for large datasets, and avoid accidental caches. Relate leaks or GC pressure to a concrete Multithreading & Concurrency scenario.
Practice with AI mock interviews
Run Java mock interviews with AI follow-ups, instant feedback, and analytics on AiLx.
Free to start · No credit card required