Multithreading & Concurrency

Multithreading & Concurrency

Difference between Implementing Runnable and Extending Thread

Carvia Tech | May 28, 2019 | 3 min read | 209 views

Difference between Implementing Runnable and Extending Thread

Read Article

Producer Consumer Problem using Blocking Queue in Java

Carvia Tech | May 28, 2019 | 3 min read | 409 views | Multithreading and Concurrency

A producer consumer problem is a typical example of multi-thread synchronization problem. It describes a scenario where some shared resource (a work queue, blockingqueue) is used by two types of threads - Producers & Consumers.

Read Article

What do you understand by Java Memory Model?

Carvia Tech | May 19, 2019 | 2 min read | 163 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

What is AtomicInteger class and how it works internally

Carvia Tech | May 19, 2019 | 2 min read | 182 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

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

Carvia Tech | May 19, 2019 | 1 min read | 59 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

How to implement Thread pool in Java without executor framework

Carvia Tech | May 05, 2019 | 3 min read | 41 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

What is Double Checked Locking Problem in Multi-Threading?

Carvia Tech | May 05, 2019 | 4 min read | 170 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 | 55 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 | 37 views

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

Read Article

What is difference between sleep() and wait() method in Java?

Carvia Tech | April 23, 2019 | 2 min read | 58 views | Multithreading and Concurrency

`wait()` and `notify()` are used in multi-threading programming for inter-thread communication, while sleep is used to control execution time of current thread.

Read Article