← Back to Java
Java

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.

Question 1
Interview Beginner
Question

What is a thread in Java?

Answer:

A thread is a lightweight unit of execution that allows concurrent execution of tasks within a process.

Question 2
Interview Beginner
Question

What is the difference between a process and a thread?

Answer:

A process is an independent program in execution, while a thread is a smaller execution unit within a process that shares resources.

Question 3
Interview Beginner
Question

What are the ways to create a thread in Java?

Answer:

A thread can be created by extending the Thread class or implementing the Runnable interface.

Question 4
Interview Beginner
Question

What is the difference between Thread and Runnable?

Answer:

Thread is a class, while Runnable is an interface. Implementing Runnable allows a class to extend another class.

Question 5
Interview Beginner
Question

What is the thread lifecycle?

Answer:

A thread moves through New, Runnable, Running, Blocked/Waiting, and Terminated states during execution.

Question 6
Interview Beginner
Question

What is synchronization?

Answer:

Synchronization controls access to shared resources, ensuring that only one thread accesses critical code at a time.

Question 7
Interview Beginner
Question

Why is synchronization needed?

Answer:

Synchronization prevents data inconsistency and race conditions when multiple threads access shared resources.

Question 8
Interview Intermediate
Question

What is a deadlock?

Answer:

A deadlock occurs when two or more threads wait indefinitely for resources held by each other.

Question 9
Interview Intermediate
Question

How can deadlocks be avoided?

Answer:

Deadlocks can be avoided through lock ordering, lock timeouts, minimizing nested locks, and using concurrent utilities.

Question 10
Interview Intermediate
Question

What is a race condition?

Answer:

A race condition occurs when multiple threads modify shared data simultaneously, producing unpredictable results.

Question 11
Interview Intermediate
Question

What is the difference between sleep() and wait()?

Answer:

sleep() pauses a thread for a specified time without releasing locks, while wait() releases the lock and waits for notification.

Question 12
Interview Intermediate
Question

What is the difference between notify() and notifyAll()?

Answer:

notify() wakes one waiting thread, whereas notifyAll() wakes all waiting threads.

Question 13
Interview Intermediate
Question

What is the volatile keyword?

Answer:

volatile ensures that variable updates are immediately visible to all threads and prevents caching inconsistencies.

Question 14
Interview Intermediate
Question

What is a thread pool?

Answer:

A thread pool is a collection of reusable worker threads that improves performance by reducing thread creation overhead.

Question 15
Interview Advanced
Question

What is the Executor Framework?

Answer:

The Executor Framework provides a high-level API for managing and executing asynchronous tasks using thread pools.

Question 16
Interview Advanced
Question

Which Java language or JDK features are essential when discussing Multithreading & Concurrency?

Answer:

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.

Question 17
Interview Advanced
Question

How does exception handling typically work around Multithreading & Concurrency in Java?

Answer:

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.

Question 18
Interview Advanced
Question

What unit-testing approach would you use for Multithreading & Concurrency?

Answer:

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.

Question 19
Interview Advanced
Question

How do equals/hashCode or identity rules affect Multithreading & Concurrency?

Answer:

Incorrect equals/hashCode break HashMap/HashSet behavior. If Multithreading & Concurrency stores objects in collections, explain the contract and mutability pitfalls.

Question 20
Interview Advanced
Question

What memory or GC concern should juniors watch with Multithreading & Concurrency?

Answer:

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