Here are 100 Java multithreading & concurrency interview questions, organized by level:
Beginner (30 Questions)
-
What’s the difference between a process and a thread?
-
How do you create a thread in Java (at least two ways)?
-
What is the Runnable interface, and how does it differ from extending
Thread? -
What is the Thread lifecycle? Name its states.
-
How do you start a thread, and what happens if you call
run()instead ofstart()? -
What does
Thread.sleep()do, and how does it differ fromObject.wait()? -
How do you make one thread wait for another to finish?
-
What is the purpose of
Thread.yield()? -
What is a daemon thread, and how do you create one?
-
How do you set and get a thread’s priority, and does it guarantee order?
-
What happens if a thread throws an unchecked exception and it’s not caught?
-
How do you handle uncaught exceptions on a per-thread basis?
-
What is synchronization, and when should you use the
synchronizedkeyword? -
How do
synchronizedmethods differ from synchronized blocks? -
What is an intrinsic lock (monitor) in Java?
-
What is reentrant synchronization?
-
How does Java prevent two threads from executing synchronized code on the same object?
-
What’s the difference between a class-level and instance-level lock?
-
What is the volatile keyword, and when is it needed?
-
How does Java’s memory model ensure visibility of shared variables?
-
What is thread safety, and how do you achieve it?
-
How do you declare and use a ThreadLocal variable?
-
What is deadlock, and what are its necessary conditions?
-
How can you detect or avoid deadlock?
-
What is livelock and how does it differ from deadlock?
-
What is starvation in multithreading?
-
How do
wait(),notify(), andnotifyAll()work? -
Why must
wait()/notify()be called from a synchronized context? -
What is spurious wakeup, and how do you guard against it?
-
How do you implement a simple producer–consumer using
wait()/notify()?
Intermediate (40 Questions)
-
What are the advantages of using the java.util.concurrent package over low-level primitives?
-
How do you create and configure a ThreadPoolExecutor?
-
What are the different executor interfaces and implementations (
Executor,ExecutorService,ScheduledExecutorService)? -
How does
Executors.newFixedThreadPool()differ fromnewCachedThreadPool()? -
What is a work queue in a thread pool, and which types exist?
-
Explain the RejectionPolicy options in
ThreadPoolExecutor. -
How do you shut down an executor gracefully vs. immediately?
-
What is a Future, and how do you retrieve its result?
-
How do you cancel a running task via its
Future? -
What is a Callable, and how does it differ from
Runnable? -
What are CountDownLatch, CyclicBarrier, and Semaphore, and when would you use each?
-
How does
Exchangerwork? Give a use-case. -
What is a Phaser, and how does it differ from
CyclicBarrier? -
What is ReadWriteLock, and why use it over a simple lock?
-
How does ReentrantLock differ from
synchronized? -
What is a fair lock vs. unfair lock?
-
How do you use
Conditionobjects with aReentrantLock? -
What is StampledLock, and when is it useful?
-
How do atomic classes (
AtomicInteger,AtomicReference, etc.) work under the hood? -
Explain compare-and-set (CAS) and how it enables lock-free algorithms.
-
What is ABA problem, and how do you mitigate it?
-
How do you build a thread-safe non-blocking stack or queue?
-
What is BlockingQueue, and name its implementations (
ArrayBlockingQueue,LinkedBlockingQueue, etc.). -
How does
PriorityBlockingQueueorder its elements? -
What is transfer queue (
LinkedTransferQueue)? -
How does Fork/Join framework work, and when would you use it?
-
What is a RecursiveAction vs. RecursiveTask?
-
How do you tune the ForkJoinPool’s parallelism level?
-
What is work-stealing, and how does the Fork/Join pool implement it?
-
How do you handle exceptions inside Fork/Join tasks?
-
What are parallel streams, and how do they relate to the Fork/Join pool?
-
What pitfalls should you watch for when using parallel streams?
-
Explain the happens-before rules in the Java Memory Model.
-
How do volatile variables establish a happens-before relationship?
-
What is safe publication, and how do you achieve it?
-
How do immutable objects help in concurrent code?
-
Explain double-checked locking and its pitfalls in Java.
-
How does
java.util.concurrentimplement time-outs on locks or queues? -
What is spin-locking, and where might it be used?
-
How can you profile or debug thread contention in a running application?
Advanced (30 Questions)
-
How would you design a high-throughput, low-latency concurrent system in Java?
-
What are non-blocking algorithms (e.g., Michael-Scott queue) and how would you implement one?
-
Explain disruptor pattern and its benefits.
-
How do you implement lock striping for higher concurrency?
-
What is false sharing, and how can you avoid it?
-
How do you manage backpressure between producers and consumers in high-load scenarios?
-
Explain reactive streams and how they relate to backpressure.
-
How would you build a multi-level caching solution with concurrency in mind?
-
What is thread affinity, and when is it useful?
-
How can ThreadLocal lead to memory leaks in application servers?
-
Describe structured concurrency (Project Loom) and its advantages.
-
How do virtual threads (Fibers) change the concurrency model?
-
What are continuations, and how might they be exposed in future Java versions?
-
How do you safely interact with native code (
JNI) from multiple threads? -
How can you optimize GC behavior in a highly concurrent application?
-
Discuss the trade-offs between blocking and non-blocking designs.
-
How would you implement a reliable messaging system with exactly-once delivery guarantees?
-
What are transactional memory concepts, and are they available in Java?
-
How do you design a parallel data processing pipeline with custom partitioning and merging?
-
What is the role of ThreadGroup, and is it still relevant?
-
How can VarHandles provide better performance or flexibility than atomic classes?
-
How do you enforce ordering constraints in a concurrent workflow?
-
What strategies exist for coordinating thousands of concurrent tasks with minimal overhead?
-
How do you implement a high-performance publish/subscribe mechanism in Java?
-
Explain lock-free snapshots or multi-version concurrency control (MVCC) in Java.
-
How would you benchmark and stress-test a concurrent data structure?
-
What is deterministic replay of multithreaded executions, and how might you achieve it?
-
How would you prevent or diagnose heisenbugs in concurrent code?
-
Discuss the future of Java concurrency beyond Loom—what features or improvements would you propose?
-
Compare Java’s concurrency model with those of other platforms (e.g., Go, Erlang, .NET).
Use these to structure your study, mock interviews, and whiteboarding. Good luck!

Comments
Post a Comment