What is a semaphore, and when to use it?

In Java’s concurrency API, a semaphore is another synchronization tool that simultaneously controls the number of threads accessing a particular resource or section of code. It manages a set of permits; threads must acquire a permit before proceeding. If a permit is available, the thread acquires it and continues execution. If not, the thread is … Read more

What is CountDownLatch and How to Use It?

In Java’s concurrency API, CountDownLatch is a synchronizer that allows one or more threads to wait for a set of operations to complete. Imagine you’re developing a server application that relies on various resources to be initialized before it can start processing requests. These resources could be things like: Loading configuration files Establishing database connections … Read more

Web Crawling in Java: A Tale of Classical Threads and Virtual Threads

A compelling narrative around web crawling in Java, contrasting classical threads with their newer counterpart: virtual threads.

Java Threads Reimagined: A Reflection on JConf Toronto 2023 and the Dawn of a New Era of Concurrency

Experience the intersection of expertise, innovation, and camaraderie at JConf Toronto 2023, a unique platform.

Unleashing the Power of Lightweight Concurrency: A Comprehensive Guide to Java Virtual Threads (Part 1)

Java Virtual Threads, also known as lightweight threads, are a new feature in Java’s Project Loom that aim to simplify concurrent programming.

Weekly Java Newsletter – Issue #4

Hi there,

I hope you had a wonderful weekend. This week was quite hectic, as usual. I gave a presentation on Project Loom to the Garden State Java User Group last week, and a similar talk is forthcoming for PhillyJUG. That’s why this week, I concentrated on currency-related articles.

Have fun reading them.

  1. Concurrency: Concurrency is an integral component of modern programming. Therefore, if we wish to be well-rounded engineers, an understanding of concurrency is crucial. Certainly, we wish to delve deeply into it, but if you are a beginner, you should take baby steps. This article provides a fundamental yet essential introduction to Java concurrency.
  2. Java Thread Programming (Part 1) | Foojay.io Today: Well, this is comparable to the above beginner threading series that I started on Fooja.io. If you are interested, please have a look and provide feedback while I continue to work on it.
  3. Concurrency in modern programming languages: Java | Technorage : This article is a part of a series where the author tries to compare the concurrency model with other programming models through benchmarking. A good read.
  4. Avoid multithreading bugs by using immutable Java records: Java concurrency works on top of the shared-memory model. Although this simplifies programming, it has side effects. It creates data races, race conditions, etc. One of the ways to deal with such a problem is to use an immutable data structure. This article explains how Java Records can help with immutability. By the way, Java Records are an essential and relatively recent addition to the Java programming language.
  5. Jakarta Concurrency: Present and Future: Jakarta EE is one of the areas of my interest. In this article, the author discusses the Concurrency Specification, it’s present and future under the umbrella of Jakarta EE. Give a read if that interests you.
  6. 5 Things You Probably Didn’t Know About Java Concurrency: If you are just beginning to learn about concurrency, or if you are a beginner or intermediate Java developer, you may find this article intriguing, as some of the concepts I present in it may be unfamiliar to you. Please let me know if this is the case.
  7. JEP 425: Using Java Virtual Threads to Deliver Improved Throughput: The virtual thread is, in fact, the next big thing in Java concurrency. It intends to revolutionize how we write concurrency code in the future. This aims to drastically reduce the effort required to write, manage, and observe high-throughput concurrent Java applications. I’m rather certain you already know about this, but in case you don’t, perhaps you should read on.
  8. JEP 428: Structured Concurrency to Simplify Java Multithreaded Programming: This is the second-best thing, in my opinion, on the Java platform to come. This aims to simplify multithreaded programming by introducing a library to treat multiple tasks running on different threads as an atomic operation. As a result, it will streamline error handling and cancellation, improve reliability, and enhance observability.
  9. Launching 10 million virtual threads with loom – Jep café #12 – Inside.java: Who doesn’t love demo? I certainly do. This brief YouTube video provides a live demonstration of the Java virtual threads included in JDK 19, and a peek at Project Loom. Have a look at it. I hope you’ll enjoy it.
  10. Project Loom and Thread Fairness: There is a lot of excitement about Project Loom. Having virtual threads, we will now be able to write blocking code confidently, aiming for higher throughput easily. However, although virtual threads are champions at blocking code, they are a terrible idea when we execute CPU-intensive work on them. This article discusses this issue, and I find it worth reading if you are interested in virtual threads.

Bonus:

Why should you read Staff Engineer: leadership beyond the management track: There is a track you could consider called the StuffPlus engineering path if you are a senior software engineer who is not yet prepared to enter management. I’m personally exploring this option.

That’s all for today!

Did you find the content valuable? Feel free to contribute by reaching out to me if you want to add or share your thoughts at @bazlur_rahman

5 Things You Probably Didn’t Know About Java Concurrency

Even while threads are helpful, they are dreadful to many developers. Here are five essential threading concepts for Java developers!

Java Thread Programming (Part 13)

What is the maximum number of worker threads we can put in a ThreadPool? Let’s find out today on Foojay’s amazing Java threading series!

Java Thread Programming (Part 12)

Let’s find out what are the ways to create ThreadPool using the Executor framework in java and use result-bearing tasks using Callable and Future

Java Thread Programming (Part 11)

Learn how to ask the executor framework at startup to provision threads for us and they will be reused as long as the application runs.