Java Concurrency and Multi-Threading

The Java platform was designed to support concurrent programming, with basic concurrency support in the Java programming language and the Java class libraries. How often do we think about concurrency while writing new code or while doing a code review with the team? A small bug could lead to endless hours of debugging applications for a production issue that is not easy to reproduce locally. 

Why do we need concurrent programming? We are in the age where we work with machines that are equipped with multi-core CPUs. The code you deliver should be optimized to run on such machines, utilizing the hardware to its fullest.  While designing a concurrent system, we should not interfere with other processes running on the CPU.  We want our application to run in its own black box without impacting other processes. These days we have multicore CPUs that can easily handle this but how was this done back in the days when the single-core was used?

Java Concurrency, Part 1: Threads

Concurrency is a game-changer for building Java applications, referring to the ability to run several programs at the same time using multiple threads. 

This post is the first in a series of posts about Java concurrency. All code shared in this article has been tested in Java 12.

Is the Book ”Java Concurrency in Practice” Still Relevant in the Era of Java 12?

One of my readers, Shobhit, asked this question on my blog post about must-read advanced Java books: is the book "Java Concurrency in Practice" still relevant? I really liked the question and thought many Java programmers might have similar thoughts whenever someone recommends this popular Java read.

When this book was first published in 2006, the Java world was still not sure of about new concurrency changes made in Java 1.5. I think this was the first big attempt to improve Java's built-in support for multi-threading and concurrency.

Java Concurrency: Count Down Latches

Hello, readers, and welcome to yet another blog in the Java Concurrency series. Today, we are going to look at the CountDownLatch class in Java, what it is, and how to use it. So, let's dive straight into it.

CountDownLatch in Java

Sometimes, we have a need to start our application only when a particular set of tasks are complete. These tasks might be running in parallel and getting completed together or at different times. Then, how do we tell our other threads that all the tasks are completed? How do we keep track of which tasks are complete and which are not? CountDownLatch is a class just for that.