Multithreading & Concurrency

Multithreading & Concurrency

What do you understand by Java Memory Model?

Carvia Tech | May 19, 2019 at 11:40 AM | 119 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 at 11:36 AM | 135 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 at 11:35 AM | 22 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

Discuss internals of a Concurrent Hashmap (CHM) in Java

Carvia Tech | May 06, 2019 at 11:59 PM | 210 views

A ConcurrentHashMap is a hashmap supporting full concurrency of retrieval via volatile reads of segments and tables without locking, and adjustable expected concurrency for updates. All the operations in this class are thread-safe.

Read Article

How to implement Thread pool in Java without executor framework

Carvia Tech | May 05, 2019 at 07:25 PM | 17 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 at 07:23 PM | 138 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 at 07:23 PM | 21 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

Producer Consumer Problem using Blocking Queue in Java

Carvia Tech | April 28, 2019 at 10:07 PM | 359 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

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

Carvia Tech | April 23, 2019 at 10:21 PM | 17 views

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

Read Article

Difference between Implementing Runnable and Extending Thread

Carvia Tech | April 23, 2019 at 10:38 AM | 174 views

Difference between Implementing Runnable and Extending Thread

Read Article