This repository contains a comprehensive set of questions designed for mastering Java Multithreading at the Architect / Technical Lead level.
The sections are categorized to cover fundamentals, advanced concepts, real-world scenarios, and leadership responsibilities.
- What are the possible thread states in Java?
- How does a thread transition from NEW to RUNNABLE?
- What does the TERMINATED state mean?
- What is the difference between thread priority levels?
- Are thread priorities guaranteed across all JVMs?
- What is the difference between user threads and daemon threads?
- How do you create a daemon thread?
- What happens if all user threads finish but daemon threads remain?
- What are thread groups in Java?
- Are thread groups recommended for modern applications?
- How do you create a thread using the Thread class?
- How do you create a thread using Runnable?
- How do you create a thread using Callable and Future?
- What are the pros/cons of implementing Runnable vs extending Thread?
- How do you stop a thread safely?
- Why is Thread.stop() deprecated?
- How do you interrupt a running thread?
- How should code handle InterruptedException?
- What is cooperative thread termination?
- What are best practices for handling thread lifecycle?
- How does the synchronized keyword work internally?
- What is a monitor in Java concurrency?
- What are intrinsic locks in Java?
- How are intrinsic locks different from explicit locks?
- What is a reentrant lock?
- How does fairness policy affect ReentrantLock?
- How do you use tryLock() with timeouts?
- What is the purpose of ReadWriteLock?
- How does ReentrantReadWriteLock improve concurrency?
- What is StampedLock and how does it differ from ReentrantLock?
- What is optimistic locking in StampedLock?
- How do condition variables work in Java?
- How do you use await() and signal() with conditions?
- What is spurious wakeup?
- Why is it important to check conditions in a loop when waiting?
- What is the difference between wait() and sleep()?
- How does notify() differ from notifyAll()?
- What happens if notify() is called with no waiting threads?
- What are lock contention and its effects?
- When should you prefer locks over synchronized blocks?
- What is the happens-before relationship?
- How does synchronized establish happens-before?
- How does volatile establish happens-before?
- How does Thread.start() establish happens-before?
- How does Thread.join() establish happens-before?
- What guarantees does volatile provide?
- Why is volatile insufficient for atomic increments?
- How does volatile prevent instruction reordering?
- What is safe publication of objects?
- What is the out-of-thin-air value problem?
- Which operations are atomic in Java?
- Why were long and double not atomic pre-Java 5?
- What’s the difference between atomicity, visibility, and ordering?
- How does synchronization guarantee visibility?
- What is instruction reordering?
- How do memory fences prevent reordering?
- How does the JVM insert memory fences implicitly?
- Why is double-checked locking broken without volatile?
- How are final fields treated specially by the JMM?
- Why are final fields “safe to publish”?
- What is ExecutorService in Java?
- How do you create a fixed thread pool?
- What is a cached thread pool?
- What is a single-threaded executor?
- What is the advantage of using thread pools?
- What is a work-stealing pool?
- How does ForkJoinPool differ from normal executors?
- What is the fork/join framework best suited for?
- What is a CompletableFuture?
- How does CompletableFuture differ from Future?
- How do you chain async tasks with CompletableFuture?
- What are blocking queues in Java concurrency?
- When to use ArrayBlockingQueue vs LinkedBlockingQueue?
- What is a PriorityBlockingQueue?
- How does SynchronousQueue work?
- What is a DelayQueue used for?
- How does CountDownLatch work?
- How does CyclicBarrier differ from CountDownLatch?
- What is a Phaser?
- How do you schedule tasks with ScheduledExecutorService?
- What is CAS (Compare-And-Swap)?
- How does CAS help avoid locks?
- What is AtomicInteger used for?
- What is AtomicLong?
- What is AtomicReference?
- How does AtomicStampedReference solve the ABA problem?
- What is AtomicMarkableReference?
- When to use LongAdder vs AtomicLong?
- What is DoubleAdder used for?
- How do lock-free queues work internally?
- What is a lock-free stack?
- What is the ABA problem in concurrency?
- How do you solve the ABA problem?
- What are VarHandles?
- How do VarHandles replace sun.misc.Unsafe?
- What are the benefits of lock-free programming?
- What are the risks of lock-free programming?
- How does CAS interact with memory fences?
- What happens when CAS fails repeatedly?
- How can lock-free structures improve throughput?
- How does ConcurrentHashMap work internally?
- What is bucket segmentation in ConcurrentHashMap?
- How did ConcurrentHashMap change after Java 8?
- What is the performance advantage of ConcurrentHashMap?
- How does CopyOnWriteArrayList work?
- When should you use CopyOnWriteArrayList?
- What are the trade-offs of CopyOnWrite collections?
- How does ConcurrentSkipListMap work?
- What is a ConcurrentSkipListSet?
- What does “weakly consistent iterator” mean?
- How are weakly consistent iterators different from fail-fast ones?
- What is the difference between synchronized collections and concurrent collections?
- When to prefer synchronized collections?
- What happens when multiple threads modify ConcurrentHashMap?
- How do concurrent collections ensure thread safety?
- What is ConcurrentLinkedQueue?
- How does ConcurrentLinkedDeque differ?
- How does LinkedBlockingDeque work?
- How do concurrent navigable maps work?
- What are the use cases for concurrent collections?
- What is the Producer-Consumer pattern?
- How can you implement Producer-Consumer with BlockingQueue?
- What is the Reader-Writer pattern?
- How is Reader-Writer implemented with ReadWriteLock?
- What is the Fork/Join divide-and-conquer pattern?
- What is the Actor model in concurrency?
- How does the Actor model prevent shared state issues?
- What role does immutability play in concurrency?
- What is an event-driven pipeline?
- How can reactive streams model pipelines?
- What is backpressure in reactive streams?
- What is the Disruptor pattern?
- What is a thread confinement pattern?
- What is the thread-per-message model?
- What is the Leader-Follower pattern?
- What is the Half-Sync/Half-Async pattern?
- How does batching improve concurrency efficiency?
- How does async message passing reduce contention?
- What are the benefits of immutability in multi-threaded design?
- What is structured concurrency?
- What is a deadlock?
- How can you detect deadlocks?
- What is a livelock?
- How does livelock differ from deadlock?
- What is thread starvation?
- How do you prevent starvation in scheduling?
- What is fairness in thread scheduling?
- How do you analyze thread dumps?
- How do you identify blocked threads?
- How do flame graphs help in debugging concurrency?
- What is lock contention?
- How do you reduce lock contention?
- What are thread profiling tools in Java?
- How do you analyze CPU vs lock bottlenecks?
- What is scalability testing for concurrency?
- How do you measure throughput under load?
- What strategies prevent deadlock?
- How do you detect contention hotspots?
- How does oversubscription of threads affect performance?
- How does context switching overhead affect performance?
- What are parallel streams in Java?
- How do parallel streams differ from manual threads?
- What is reactive programming?
- What is Reactor?
- What is RxJava?
- How do reactive streams differ from futures?
- What is async I/O?
- How does async I/O differ from thread-per-request?
- What is Project Loom?
- What are virtual threads?
- How do virtual threads reduce resource usage?
- How does structured concurrency improve readability?
- What are the risks of parallel streams?
- How do you handle blocking calls in reactive systems?
- What is a scheduler in reactive frameworks?
- How does backpressure work in Reactor?
- How does reactive programming handle errors?
- What is the difference between reactive and traditional thread pools?
- How do virtual threads compare to coroutines?
- How do you migrate from thread pools to virtual threads?
- How would you design a high-throughput data pipeline in Java?
- When to use thread-per-request vs event-loop model?
- How do you design batch processing with concurrency?
- How do you design real-time streaming with concurrency?
- How do you apply CQRS with concurrency?
- How do you design for retries in concurrent systems?
- How do you implement timeouts in multithreaded systems?
- What is a circuit breaker pattern in concurrency?
- How do you design distributed locks using Redis?
- How do you implement distributed coordination with Zookeeper?
- How do you review code for concurrency issues?
- What are common concurrency code smells?
- What is a concurrency checklist for teams?
- How do you teach concurrency to juniors?
- How do you explain deadlocks simply?
- How do you enforce concurrency best practices org-wide?
- How do you balance readability vs performance in threaded code?
- What are common concurrency pitfalls in code reviews?
- How do you mentor developers on concurrency?
- How do you document concurrency decisions for architecture?