Exploring the Impact of Stack Size on JVM Thread Creation: A Myth Debunked

Among Java developers, a prevailing assumption is that the number of native threads that can be created within the Java Virtual Machine (JVM) is linked to the stack size. To scrutinize this widespread notion, an experiment was conducted. The results revealed that stack size plays a less significant role in native thread creation than previously thought.

The Experiment

The experiment utilized the following Java program, which continuously creates threads and counts them using an AtomicInteger.

Book Review: “OpenJDK Migration for Dummies”

The subject of Java licensing and OpenJDK migration is complex and vital to many software engineers. I am no different. It's a topic often shrouded in legal jargon and technicalities, making it difficult to approach. OpenJDK Migration for Dummies

"OpenJDK Migration for Dummies" by Simon Ritter offers a fresh perspective, breaking down these challenges into digestible segments (get it for free here).

The book directly speaks to my core expertise in Java, providing clarity and guidance.

The Evolution of Java: Challenging Stereotypes and Embracing Modernity

On a flight from Zurich to Toronto, I found myself in an engaging conversation with a fellow passenger. Among various topics, our conversation navigated toward our careers and, inevitably, as I am a Java developer, towards the world of Java.

This gentleman, having worked with Java some 15-20 years ago, was surprised to learn that I still actively use the language. "Isn't it slow?" he questioned. His question echoed a stereotype that I have often encountered, one that has stuck to Java since its earlier days.

Exploring Java 21’s Intriguing Additions (Part 1)

Java 21 is going to introduce several intriguing additions that enhance the language's capabilities. This article aims to discuss a few notable features that stand out, providing an overview of their functionalities and potential use cases.

Character Enhancements

  1. Character.isEmoji(int codePoint): This method determines whether a character is considered an emoji based on its Unicode properties defined in Unicode Emoji (Unicode Emoji Technical Standard #51). For example, executing Character.isEmoji(9203) would return true for the character ⏳, which has the code point 9203.
  2. Character.isEmojiPresentation(int codePoint): Similar to isEmoji(), this method checks if a character has the Emoji Presentation property. It helps identify characters that display as emojis when rendered.

Example:

Comparing Map.of() and New HashMap() in Java

Java is a popular programming language used for developing a wide range of applications, including web, mobile, and desktop applications. It provides many useful data structures for developers to use in their programs, one of which is the Map interface. The Map interface is used to store data in key-value pairs, making it an essential data structure for many applications.

In this article, we will discuss the use of Map.of() and new HashMap<>() in Java, the difference between them, and the benefits of using Map.of().

Optional in Java: A Swiss Army Knife for Handling Nulls and Improving Code Quality

In Java, dealing with null values can be a real headache. Nulls can cause all sorts of problems in your code, from NullPointerExceptions to convoluted if statements and error-prone logic. Fortunately, Java 8 introduced the Optional class, which offers a simple and powerful way to handle nulls and improve code quality. Optional is a container object that may or may not contain a non-null value and provides a range of practical methods for working with its contents. In this article, we'll explore the many use cases of Optional in Java and show you how to use this powerful class to write cleaner, more expressive, and more resilient code.

So let's deep dive into a few examples of uses of Optionals.

Avoiding NullPointerExceptions

One of the most common use cases of Optional is to avoid NullPointerExceptions. By wrapping a potentially null value in an Optional, you can safely access the value without risking a NullPointerException. For example, if you have a method that returns a value that might be null, you can return an Optional instead and then use Optional methods to access the value safely.

Java Bytecode: Journey to the Wonderland (Part 3)

Our previous article unpacked bytecode further and discussed ConstantPool. Today, I'll go through several resources for working with it now.

Java bytecode is the Java Virtual Machine's (JVM) intermediate representation of Java code. While Java bytecode is not meant to be human-readable, it may be edited and manipulated for several reasons. This article examines the tools and methods used to change and work with Java bytecode.

Why Many Developers Don’t Write or Give Talks and How To Overcome Challenges

I asked on Twitter and LinkedIn why many developers don’t write or give talks, and I was amused by the response I received. This article is about that.

The Problems

It turns out developers do not write blogs or give presentations for a variety of reasons. Some developers may believe they lack interesting experiences or information to share or feel that they are not experts in their profession. Others may be shy or fearful of public speaking. Another reason is due to their hectic schedules, individuals may not have time to write about or discuss their jobs.

Java Bytecode Simplified: Journey to the Wonderland (Part 2)

Our previous article introduced bytecode and discussed what it includes. This article will delve a bit deeper into ConstantPool.

Highlights

  • Bytecode is a representation that is abstract in nature. They are fictitious codes for a fictitious machine known as the Java virtual machine. The Java virtual machine is a piece of software that interprets bytecode.
  • The JVM is a stack-based computer. Real CPUs are register-based systems and execute machine code. Java is compiled into bytecode, an intermediate form, which is then executed by the just-in-time (JIT) compiler, which generates machine code.

Before going any further, let's explore javap, which is a very handy tool for deconstructing byte code.

Java Thread Programming (Part 3)

Continuing from part 2, let’s start this article with a bit of context first (and if you don’t like reading text, you can skip this introduction, and go directly to the section below where I discuss pieces of code).

Context

  • When we start an application program, the operating system creates a process.
  • Each process has a unique id (we call it a PID) and a memory boundary.
  • A process allocates its required memory from the main memory, and it manipulates data within a boundary.
  • No other process can access the allocated memory that is already acquired by a process.
  • It works like a sandbox, and in that way, avoids processes stepping on one another's feet.
  • Ideally, we can have many small processes to run multiple things simultaneously on our computers and let the operating system's scheduler schedule them as it sees fit.
  • In fact, this is how it was done before the development of threads. However, when we want to do large pieces of work, breaking them into smaller pieces, we need to accumulate them once they are finished.
  • And not all tiny pieces can be independent, some of them must rely on each other, so we need to share information amongst them.
  • To do that, we use inter-process communication. The problem with this idea is that having too many processes on a computer and then communicating with each other isn’t cheap. And precisely that is where the notion of threads comes into the picture.

The idea of the thread is that a process can have many tiny processes within itself. These small processes can share the memory space that a process acquires. These little processes are called "threads." So the bottom line is that threads are independent execution environments in the CPU and share the same memory space. That allows them faster memory access and better performance.

Top 10 Java Language Features

Every programming language provides ways to express our ideas and then translate them into reality.

Some are unique to that particular language and some are common to many other programming languages.

Top 7 Features in Jakarta EE 10 Release

Java EE was the dominant force behind all the enterprise development in Java. Lately, it was renamed Jakarta EE, transitioning from JCP to Eclipse Foundation.

This transition opened the door to open governess, open compatibly testing (earlier Technology Compatibility Kit -TCK was closed source), and of course, open-source. That means no specific vendor has more influence than others; it's more distributed now.

Java Bytecode Simplified: Journey to the Wonderland (Part 1)

There are two ways to see a thing. One, see it as it appears to us; two, see it and appreciate it. For example, we get light when we switch on a lightbulb. We press the button and then get busy with our life. Pretty simple, but boring. On the other hand, if we know how the light gets energy from an electrical power grid far from our home with wires, and while traveling through the wires and filament, the filament heats up and starts emitting photons, we get to see in the light; we can then appreciate the blessing.

In the same way, when we write a piece of code, and if we know the mechanism behind it, we can then appreciate it more, how excellent engineering effort went into it, making our life so amazing.