Multithreading & Concurrency

Multithreading & Concurrency

Troubleshooting Deadlock in Java

Carvia Tech | August 11, 2020 | 4 min read | 2 views

In this post we will describe what deadlock is, how to troubleshoot it and how to reproduce it using Java language

Read Article

Custom Thread pool implementation in Java

Carvia Tech | July 25, 2020 | 3 min read | 4,666 views

thread pool executor requires a Queue for holding tasks and a collection of Worker Threads that will pick up tasks from the work queue start running them.

Read Article

Producer Consumer Problem using Blocking Queue in Java

Carvia Tech | August 31, 2019 | 3 min read | 2,024 views | Multithreading and Concurrency

A producer consumer problem is a typical example of multi-thread synchronization problem where some shared resource (a work queue, blockingqueue) is used by two types of threads - Producer & Consumer

Read Article

What is AtomicInteger class and how it works internally

Carvia Tech | August 03, 2019 | 2 min read | 963 views | Multithreading and Concurrency

AtomicInteger class was added in Java 5 that utilizes non-blocking concurrency for thread-safety, providing better throughput in highly concurrent environments.

Read Article

Difference between Implementing Runnable and Extending Thread

Carvia Tech | July 30, 2019 | 3 min read | 911 views

Implementing Runnable and giving it to a thread is form of composition while Extending Thread is a form of inheritance. Since we are not really specializing Thread's behaviour in this case, Implementing Runnable will make more sense.

Read Article

What do you understand by Java Memory Model?

Carvia Tech | May 19, 2019 | 2 min read | 698 views | Multithreading and Concurrency

Java Memory Model defines the legal interaction of threads with the memory in a real computer system. It determines when a Thread can reliably see writes to variables made by other threads.

Read Article

Design an Immutable class that has an java.util.Date member

Carvia Tech | May 19, 2019 | 1 min read | 2,273 views | Multithreading and Concurrency

As we know that java.util.Date is not immutable, we need to make a defensive copy of java.util.Date field while returning a reference to this instance variable.

Read Article

What is Double Checked Locking Problem in Multi-Threading?

Carvia Tech | May 05, 2019 | 4 min read | 229 views

This article is about Java Memory Model and Double Checked Locking Problem for Singleton creation in Multi-Threading

Read Article

How will you implement your custom threadsafe Semaphore in Java

Carvia Tech | May 05, 2019 | 2 min read | 837 views

We can implement a custom semaphore using `ReentrantLock` and `Condition` classes provided by Java. However this implementation is just for illustration purpose and not for production use.

Read Article

How will you increment each element of an Integer array, using parallel operation

Carvia Tech | April 23, 2019 | 2 min read | 347 views

Java 7 `ForkJoinPool`, Java 8 `Arrays.parallelSetAll` can be used for performing parallel operations on an integer array.

Read Article