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.

The 5 Most Pivotal and Innovative Additions to OpenJDK 19

Although OpenJDK 19 is not an LTS, it is still a significant release, in my opinion. It includes several game-changing features that will alter the Java landscape.

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

Your Java Code in the Fastlane: Creating a Million Virtual Threads Using Project Loom to Improve Throughput

Abstract Project Loom introduces virtual threads, lightweight threads that aim to dramatically reduce the effort of writing, maintaining, and monitoring high-throughput concurrent applications with the Java platform. We need threads to achieve high throughput. However, threads are not cheap and are limited in number. To get around this problem, various alternatives such as the reactive … Read more

How to Enable Java Preview Features and Run Code from IntelliJ IDEA

JEP 425: Virtual Threads (Preview) has been proposed recently. I wanted to give it a try it on my favorite IDE, this article shows you how to do that in IntelliJ IDEA