educative.io

Java Multithreading for Senior Engineering Interviews (C. H. Afzal)


Java Thread Basics - Future Interface This lesson discusses the Future interface. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/B8rnpMLy3LQ). Multithreading in Java - Spurious Wakeups Have questions about Spurious Wakeups? Go for it! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/m28kJM5pKYE). Multithreading in Java - Multithreading in Java Part I A brief discussion of Java's basic concurrency constructs such as synchronized, reentrant locks, interrupted exception, etc. that are required to solve multithreading problems asked in interviews. Multithreading in Java - Multithreading in Java Part II This chapter continues the discussion on common java multithreading constructs and patterns including interrupted exception, volatile keyword, reentrant lock and condition variable. Multithreading in Java - Multithreading in Java Part III This chapter continues the discussion on common java multithreading constructs and patterns including semaphores, addressing missed signals, lock fairness, thread-pools and spurious wake-ups. Interview Practice Problems - ReadWrite Lock We discuss a common interview question involving synchronization of multiple reader threads and a single writer thread. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/B892KY261z2). The Basics - Program vs Process vs Thread This lesson discusses the differences between a program, process and a thread. Also included is an example of a thread-unsafe program. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/m2G48X18NDO). Beyond the Interview - Next Steps Moving from interview mindset to learning mindset. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/3jjMDko8yLn). Revision & Quizzes - Quiz 3 Questions on how threads can be created View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/mE6O9OwyM2O). The Basics - I/O Bound vs CPU Bound We delve into the characteristics of programs with different resource-use profiles and how that can affect program design choices. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/gxWZYVjMMPZ). The Basics - Semaphore vs Monitor This lesson discusses the differences between a monitor and a semaphore. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/YQQ3WQYMk6M). Interview Practice Problems - Epilogue Closing remarks on the interview process. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/3j6NnJrpp5p). Revision & Quizzes - Quiz 8 Questions on working with ThreadLocal variables View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/B8nrBALMqvk). Interview Practice Problems - Implementing a Barrier This lesson discusses how a barrier can be implemented in Java. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/xV9mMjj74gE). Interview Practice Problems - Implementing Semaphore Learn how to design and implement a simple semaphore class in Java. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/m22Gymjp4mG). Java Thread Basics - Concurrent Collections This lesson gives a brief introduction about Java's concurrent collection classes. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/m20yXj7LQgE). Revision & Quizzes - Quiz 4 Question on use of synchronized View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/B81OVElBoYW). Revision & Quizzes - Quiz 7 Threaded design and thread-safety questions. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/xVlg08AR9RJ). Interview Practice Problems - Superman Problem This lesson is about correctly implementing a singleton pattern in Java View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/3jYKmrVAPGQ). Bonus Questions - Fizz Buzz Problem This problem explores a multi-threaded solution to the very common Fizz Buzz programming task View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/NEK1rpo8AqL). Java Thread Basics - ThreadLocal This lesson discusses thread local storage View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/NEX3V5xA9EL). Multithreading in Java - Semaphore in Java Have questions about Semaphore in Java? Go for it! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/B813gM8Jp1x). Interview Practice Problems - ... continued This lesson continues the discussion on implementing the Singleton pattern in Java. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/Y5o1MprBByM). The Basics - Moore's Law Discusses impact of Moore's law on concurrency. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/Y5mg0BY401O). Multithreading in Java - Wait & Notify Have questions about Wait & Notify? Go for it! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/7npA3GYgO6j). Multithreading in Java - Thready Safety & Synchronized This lesson explains thread-safety and the use of the synchronized keyword. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/B8Qq3mnPolJ). Bonus Questions - Ordered Printing This problem is about imposing an order on thread execution. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/B8Yz93o3w4Y). Revision & Quizzes - Quiz 5 Exercise on how to make classes thread-safe View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/m2O3BywvQ4n). Java Thread Basics - Executor Framework This lesson discusses thread management using executors. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/NEXpJ8m06w6). Multithreading in Java - Miscellaneous Topics Have questions about Miscellaneous Topics? Go for it! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/qVZP0vnRL52). Multithreading in Java - Volatile Have questions about Volatile? Go for it! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/gxkEvN1L1xZ). Interview Practice Problems - Unisex Bathroom Problem A synchronization practice problem requiring us to synchronize the usage of a single bathroom by both the genders. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/m2yDVZnQ8lG). The Basics - Java's Monitor & Hoare vs Mesa Monitors Continues the discussion of the differences between a mutex and a monitor and also looks at Java's implementation of the monitor. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/xV1qvj6PKkJ). Java Thread Basics - Callable Interface This lesson discusses the Callable interface. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/YQqmNz52pZn). Interview Practice Problems - Rate Limiting Using Token Bucket Filter Implementing rate limiting using a naive token bucket filter algorithm. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/qVl160R3xjk). Revision & Quizzes - Quiz 2 Questions on thread-safety and race conditions View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/7nnzvxKmvKQ). Java Thread Basics - Executor Implementations Have questions about Executor Implementations? Go for it! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/NEEvMymXRQp). Java Thread Basics - CyclicBarrier Have questions about CyclicBarrier? Go for it! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/q2NLpkzMDNG). Java Thread Basics - CountDownLatch Have questions about CountDownLatch? Go for it! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/gkw5QKGDwJZ). The Basics - Amdahl's Law Blindly adding threads to speed up program execution may not always be a good idea. Find out what Amdahl's Law says about parallelizing a program View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/7n9N5JMAjgQ). The Basics - Cooperative Multitasking vs Preemptive Multitasking This lesson details the differences between the two common models of multitasking. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/m2WBpO2rlKp). Interview Practice Problems - Multithreaded Merge Sort Learn how to perform Merge sort using threads. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/xVlZ3BD03l3). The Basics - Synchronous vs Asynchronous This lesson discusses the differences between asynchronous and synchronous programming which are often talked about in the context of concurrency. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/q20Mv1m86Wy). The Basics - Deadlocks, Liveness & Reentrant Locks We discuss important concurrency concepts deadlock, liveness, live-lock, starvation and reentrant locks in depth. Also included are executable code examples for illustrating these concepts. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/JYzvKPXyA5P). Interview Practice Problems - Thread Safe Deferred Callback Asynchronous programming involves being able to execute functions at a future occurrence of some event. Designing a thread-safe deferred callback class becomes a challenging interview question. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/xV91vr9pZoP). Interview Practice Problems - Asynchronous to Synchronous Problem A real-life interview question asking to convert asynchronous execution to synchronous execution. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/Y5xJN3BAlWK). The Basics - Mutex vs Monitor Learn what a monitor is and how it is different than a mutex. Monitors are advanced concurrency constructs and specific to languages frameworks. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/7nA1nGn3V6A). Java Memory Model - The happens-before Relationship This lesson continues the in-depth discussion of Java memory model View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/B8ngJnrBNoo). Revision & Quizzes - Quiz 6 Questions regarding memory visibility in multithreaded scenarios View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/YQ5mZGN267W). Java Thread Basics - CompletionService Interface This lesson talks about how to batch multiple tasks together View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/7n94JNyPOMw). Java Memory Model - Reordering Effects This lesson discusses the compiler, runtime or hardware optimizations that can cause reordering of program instructions View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/gx7wZzWn5Vj). Java Thread Basics - Thread Pools This lesson introduces thread pools and their utility in concurrent programming. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/qVDnLQ75r5G). The Basics - Introduction This lesson details the reasons why threads exist and what benefit do they provide. We also discuss the problems that come with threads. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/m2ygV4E81AR). Java Memory Model - Java Memory Model This lesson lays out the ground work for understanding the Java Memory Model. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/7nW0RlAXY6B). Interview Practice Problems - Barber Shop This lesson visits the synchronization issues when programmatically modeling a hypothetical barber shop and how they are solved using Java's concurrency primitives. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/NEEDzxZgrY6). Bonus Questions - Printing Foo Bar n Times Learn how to execute threads in a specific order for a user specified number of iterations. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/Y5PWrR8DrN2). Revision & Quizzes - Quiz 1 Have questions about Quiz 1? Go for it! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/qVZ3kKx2A2R). Java Thread Basics - Setting-up Threads This lesson discusses how threads can be created in Java. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/xV8p1GA6K0r). The Basics - Mutex vs Semaphore The concept of and the difference between a mutex and a semaphore will draw befuddled expressions on most developers' faces. We discuss the differences between the two most fundamental concurrency constructs offered by almost all language frameworks. Difference between a mutex and a semaphore makes a pet interview question for senior engineering positions! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/7nAZrnYW9rG). The Basics - Concurrency vs Parallelism This lesson clarifies the common misunderstandings and confusions around concurrency and parallelism. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/xlJNV4EzoGl). The Basics - Throughput vs Latency This lessons discusses throughput and latency in the context of concurrent systems. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/YQL98vQXOnY). Java Thread Basics - Types of Thread Pools This lesson details the different types of thread pools available in the Java class library. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/B8RPL3VEl8N). The Basics - Critical Sections & Race Conditions This section exhibits how incorrect synchronization in a critical section can lead to race conditions and buggy code. The concepts of critical section and race condition are explained in depth. Also included is an executable example of a race condition. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/B8rpM8E16LQ). Multithreading in Java - Interrupting Threads Have questions about Interrupting Threads? Go for it! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/RM5jZn2EzYY). Multithreading in Java - Reentrant Locks & Condition Variables Have questions about Reentrant Locks & Condition Variables? Go for it! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/xVLnpgY8Pnz). Multithreading in Java - Missed Signals Have questions about Missed Signals? Go for it! View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/qVQEWgLOxlG). Interview Practice Problems - Uber Ride Problem This lesson solves the constraints of an imaginary Uber ride problem where Republicans and Democrats can't be seated as a minority in a four passenger car. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/3jyvQ3pg6KO). Interview Practice Problems - Dining Philosophers This chapter discusses the famous Dijkstra's Dining Philosopher's problem. Two different solutions are explained at length. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/NE5LpPrWrKv). Bonus Questions - Printing Number Series (Zero, Even, Odd) This problem is about repeatedly executing threads which print a specific type of number. Another variation of this problem; print even and odd numbers; utilizes two threads instead of three. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/g2yrV93x6M9). Bonus Questions - Build a Molecule This problem simulated the creation of water molecule by grouping three threads representing Hydrogen and Oxygen atoms. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/RLm3lqA5gpV). Java Thread Basics - An Example: Timer vs ScheduledThreadPool Contrasting Timer and ScheduledThreadPool View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/xVgDXNBNNK9). Java Thread Basics - Basic Thread Handling This lesson shows various thread handling methods with examples. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/JYEJ31VJ09K). Interview Practice Problems - Blocking Queue | Bounded Buffer | Consumer Producer Classical synchronization problem involving a limited size buffer which can have items added to it or removed from it by different producer and consumer threads. This problem is known by different names: consumer producer problem, bounded buffer problem or blocking queue problem. View the lesson [here](https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews/B8OO0L8gRkW).
About the Java Multithreading for Senior Engineering Interviews (C. H. Afzal) category [Java Multithreading for Senior Engineering Interviews (C. H. Afzal)] (1)
When should we consider unlock() in finally block and when to unlock normally? [Interview Practice Problems - Thread Safe Deferred Callback] (1)
Semaphores are lightweight when compared to monitors? [The Basics - Semaphore vs Monitor] (1)
Blocking queue size is given 5, After running the entire program, I could see 6 enqueue operations in first place? [Interview Practice Problems - Blocking Queue | Bounded Buffer | Consumer Producer] (1)
Threads start and join question [The Basics - Introduction] (1)
No starvation for each grender [Interview Practice Problems - Unisex Bathroom Problem] (1)
Why did we use notifyAll() instead of notify() [Interview Practice Problems - Unisex Bathroom Problem] (1)
Difference between the rate limiter with deamon thread and without [Interview Practice Problems - Rate Limiting Using Token Bucket Filter] (1)
Is it a typo? Should be "capacity one" instead of "size one" [Interview Practice Problems - Blocking Queue | Bounded Buffer | Consumer Producer] (1)
Is multithreaded always faster than single threaded? [The Basics - Introduction] (2)
How to make thread safe? [Multithreading in Java - Thready Safety & Synchronized] (1)
Are cells inside array volatile? [Interview Practice Problems - Asynchronous to Synchronous Problem] (1)
Why can't we simply move synchronization logic to main method? [Interview Practice Problems - Asynchronous to Synchronous Problem] (1)
Could you please evaluate my solution? [Interview Practice Problems - Unisex Bathroom Problem] (1)
Why not to notifyAll? [Interview Practice Problems - Blocking Queue | Bounded Buffer | Consumer Producer] (1)
Why get a non-zero value on Thread Unsafe Class? [The Basics - Program vs Process vs Thread] (3)