Home
Gaurav's GitHub Page
Cancel

Java Multithreading - Wait and Notify

This following post is based on the Udemy Course: Java Multithreading wait() The wait() method is a part of java.lang.Object class. When wait() method is called, the calling thread stops its ex...

Java Multithreading - Producer/Consumer

This following post is based on the Udemy Course: Java Multithreading Blocking Queue (thread-safe queue implementation) A Queue that additionally supports operations that wait for the queue to ...

Design Pattern: Prototype

PROTOTYPE IDEA Imagine a situation where creating an object is a costly task. This can happen when we need certain information from a database or external service before we can create the object....

Java Multithreading - Countdown Latches

This following post is based on the Udemy Course: Java Multithreading A synchronization aid that allows one or more threads to wait until a set of operations being performed in other threads ...

Design Pattern: Builder

BUILDER Thought Process: We need to create an object of a class which has numerous attributes and they need some kind of validation before we create the object Although we can directly use a...

Java Multithreading - Thread Pools

This following post is based on the Udemy Course: Java Multithreading We will use the ExecutorService class to create a thread pool. Think of it as have multiple threads which will act as worker...

Design Pattern: Singleton

SINGLETON The objective is to ensure that a single object of a particular class can exist for an app. Thought Process: We will have to make the constructor of that class private so that other...

Java Multithreading - Multiple Locks; Using Synchronized Code Blocks

This following post is based on the Udemy Course: Java Multithreading Basic App without threads package demo; public class App { public static void main(String[] args) { //create a new ...

Java Multithreading - The Synchronized Keyword

This following post is based on the Udemy Course: Java Multithreading In the following code, the result of sysout(count) will be 0. This is because, even though we have started the two threads t...

Java Multithreading - Basic Thread Synchronization

This following post is based on the Udemy Course: Java Multithreading When data is shared between multiple threads, a common issue arises with data caching. In the following example, there is a ...