Thanks to visit codestin.com
Credit goes to github.com

Skip to content

metodiev/Java-Multithreading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Multithreading Architects Technical Leads

Java Multithreading for Architects and Technical Leads

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.

1. Thread Fundamentals

  1. What are the possible thread states in Java?
  2. How does a thread transition from NEW to RUNNABLE?
  3. What does the TERMINATED state mean?
  4. What is the difference between thread priority levels?
  5. Are thread priorities guaranteed across all JVMs?
  6. What is the difference between user threads and daemon threads?
  7. How do you create a daemon thread?
  8. What happens if all user threads finish but daemon threads remain?
  9. What are thread groups in Java?
  10. Are thread groups recommended for modern applications?
  11. How do you create a thread using the Thread class?
  12. How do you create a thread using Runnable?
  13. How do you create a thread using Callable and Future?
  14. What are the pros/cons of implementing Runnable vs extending Thread?
  15. How do you stop a thread safely?
  16. Why is Thread.stop() deprecated?
  17. How do you interrupt a running thread?
  18. How should code handle InterruptedException?
  19. What is cooperative thread termination?
  20. What are best practices for handling thread lifecycle?

2. Synchronization and Locks

  1. How does the synchronized keyword work internally?
  2. What is a monitor in Java concurrency?
  3. What are intrinsic locks in Java?
  4. How are intrinsic locks different from explicit locks?
  5. What is a reentrant lock?
  6. How does fairness policy affect ReentrantLock?
  7. How do you use tryLock() with timeouts?
  8. What is the purpose of ReadWriteLock?
  9. How does ReentrantReadWriteLock improve concurrency?
  10. What is StampedLock and how does it differ from ReentrantLock?
  11. What is optimistic locking in StampedLock?
  12. How do condition variables work in Java?
  13. How do you use await() and signal() with conditions?
  14. What is spurious wakeup?
  15. Why is it important to check conditions in a loop when waiting?
  16. What is the difference between wait() and sleep()?
  17. How does notify() differ from notifyAll()?
  18. What happens if notify() is called with no waiting threads?
  19. What are lock contention and its effects?
  20. When should you prefer locks over synchronized blocks?

3. Java Memory Model

  1. What is the happens-before relationship?
  2. How does synchronized establish happens-before?
  3. How does volatile establish happens-before?
  4. How does Thread.start() establish happens-before?
  5. How does Thread.join() establish happens-before?
  6. What guarantees does volatile provide?
  7. Why is volatile insufficient for atomic increments?
  8. How does volatile prevent instruction reordering?
  9. What is safe publication of objects?
  10. What is the out-of-thin-air value problem?
  11. Which operations are atomic in Java?
  12. Why were long and double not atomic pre-Java 5?
  13. What’s the difference between atomicity, visibility, and ordering?
  14. How does synchronization guarantee visibility?
  15. What is instruction reordering?
  16. How do memory fences prevent reordering?
  17. How does the JVM insert memory fences implicitly?
  18. Why is double-checked locking broken without volatile?
  19. How are final fields treated specially by the JMM?
  20. Why are final fields “safe to publish”?

4. Concurrency Utilities

  1. What is ExecutorService in Java?
  2. How do you create a fixed thread pool?
  3. What is a cached thread pool?
  4. What is a single-threaded executor?
  5. What is the advantage of using thread pools?
  6. What is a work-stealing pool?
  7. How does ForkJoinPool differ from normal executors?
  8. What is the fork/join framework best suited for?
  9. What is a CompletableFuture?
  10. How does CompletableFuture differ from Future?
  11. How do you chain async tasks with CompletableFuture?
  12. What are blocking queues in Java concurrency?
  13. When to use ArrayBlockingQueue vs LinkedBlockingQueue?
  14. What is a PriorityBlockingQueue?
  15. How does SynchronousQueue work?
  16. What is a DelayQueue used for?
  17. How does CountDownLatch work?
  18. How does CyclicBarrier differ from CountDownLatch?
  19. What is a Phaser?
  20. How do you schedule tasks with ScheduledExecutorService?

5. Atomic Operations and Lock-Free

  1. What is CAS (Compare-And-Swap)?
  2. How does CAS help avoid locks?
  3. What is AtomicInteger used for?
  4. What is AtomicLong?
  5. What is AtomicReference?
  6. How does AtomicStampedReference solve the ABA problem?
  7. What is AtomicMarkableReference?
  8. When to use LongAdder vs AtomicLong?
  9. What is DoubleAdder used for?
  10. How do lock-free queues work internally?
  11. What is a lock-free stack?
  12. What is the ABA problem in concurrency?
  13. How do you solve the ABA problem?
  14. What are VarHandles?
  15. How do VarHandles replace sun.misc.Unsafe?
  16. What are the benefits of lock-free programming?
  17. What are the risks of lock-free programming?
  18. How does CAS interact with memory fences?
  19. What happens when CAS fails repeatedly?
  20. How can lock-free structures improve throughput?

6. Concurrent Collections

  1. How does ConcurrentHashMap work internally?
  2. What is bucket segmentation in ConcurrentHashMap?
  3. How did ConcurrentHashMap change after Java 8?
  4. What is the performance advantage of ConcurrentHashMap?
  5. How does CopyOnWriteArrayList work?
  6. When should you use CopyOnWriteArrayList?
  7. What are the trade-offs of CopyOnWrite collections?
  8. How does ConcurrentSkipListMap work?
  9. What is a ConcurrentSkipListSet?
  10. What does “weakly consistent iterator” mean?
  11. How are weakly consistent iterators different from fail-fast ones?
  12. What is the difference between synchronized collections and concurrent collections?
  13. When to prefer synchronized collections?
  14. What happens when multiple threads modify ConcurrentHashMap?
  15. How do concurrent collections ensure thread safety?
  16. What is ConcurrentLinkedQueue?
  17. How does ConcurrentLinkedDeque differ?
  18. How does LinkedBlockingDeque work?
  19. How do concurrent navigable maps work?
  20. What are the use cases for concurrent collections?

7. Concurrency Patterns

  1. What is the Producer-Consumer pattern?
  2. How can you implement Producer-Consumer with BlockingQueue?
  3. What is the Reader-Writer pattern?
  4. How is Reader-Writer implemented with ReadWriteLock?
  5. What is the Fork/Join divide-and-conquer pattern?
  6. What is the Actor model in concurrency?
  7. How does the Actor model prevent shared state issues?
  8. What role does immutability play in concurrency?
  9. What is an event-driven pipeline?
  10. How can reactive streams model pipelines?
  11. What is backpressure in reactive streams?
  12. What is the Disruptor pattern?
  13. What is a thread confinement pattern?
  14. What is the thread-per-message model?
  15. What is the Leader-Follower pattern?
  16. What is the Half-Sync/Half-Async pattern?
  17. How does batching improve concurrency efficiency?
  18. How does async message passing reduce contention?
  19. What are the benefits of immutability in multi-threaded design?
  20. What is structured concurrency?

8. Performance and Debugging

  1. What is a deadlock?
  2. How can you detect deadlocks?
  3. What is a livelock?
  4. How does livelock differ from deadlock?
  5. What is thread starvation?
  6. How do you prevent starvation in scheduling?
  7. What is fairness in thread scheduling?
  8. How do you analyze thread dumps?
  9. How do you identify blocked threads?
  10. How do flame graphs help in debugging concurrency?
  11. What is lock contention?
  12. How do you reduce lock contention?
  13. What are thread profiling tools in Java?
  14. How do you analyze CPU vs lock bottlenecks?
  15. What is scalability testing for concurrency?
  16. How do you measure throughput under load?
  17. What strategies prevent deadlock?
  18. How do you detect contention hotspots?
  19. How does oversubscription of threads affect performance?
  20. How does context switching overhead affect performance?

9. Reactive and Modern Approaches

  1. What are parallel streams in Java?
  2. How do parallel streams differ from manual threads?
  3. What is reactive programming?
  4. What is Reactor?
  5. What is RxJava?
  6. How do reactive streams differ from futures?
  7. What is async I/O?
  8. How does async I/O differ from thread-per-request?
  9. What is Project Loom?
  10. What are virtual threads?
  11. How do virtual threads reduce resource usage?
  12. How does structured concurrency improve readability?
  13. What are the risks of parallel streams?
  14. How do you handle blocking calls in reactive systems?
  15. What is a scheduler in reactive frameworks?
  16. How does backpressure work in Reactor?
  17. How does reactive programming handle errors?
  18. What is the difference between reactive and traditional thread pools?
  19. How do virtual threads compare to coroutines?
  20. How do you migrate from thread pools to virtual threads?

10. System Design Scenarios

  1. How would you design a high-throughput data pipeline in Java?
  2. When to use thread-per-request vs event-loop model?
  3. How do you design batch processing with concurrency?
  4. How do you design real-time streaming with concurrency?
  5. How do you apply CQRS with concurrency?
  6. How do you design for retries in concurrent systems?
  7. How do you implement timeouts in multithreaded systems?
  8. What is a circuit breaker pattern in concurrency?
  9. How do you design distributed locks using Redis?
  10. How do you implement distributed coordination with Zookeeper?

11. Leadership and Review Skills

  1. How do you review code for concurrency issues?
  2. What are common concurrency code smells?
  3. What is a concurrency checklist for teams?
  4. How do you teach concurrency to juniors?
  5. How do you explain deadlocks simply?
  6. How do you enforce concurrency best practices org-wide?
  7. How do you balance readability vs performance in threaded code?
  8. What are common concurrency pitfalls in code reviews?
  9. How do you mentor developers on concurrency?
  10. How do you document concurrency decisions for architecture?

About

Java Multithreading

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages