Skip to main content

Java 21 adds virtual threads preview and generational ZGC

Java 21 is here, and it includes many improvements, such as the preview of virtual threads and the final version of the generational ZGC.

Most updates in Java are categorized into different named projects. In this release the features come from three projects: Project Loom, which has to do with concurrency in Java; Project Panama, which is improving how you can connect Java and native code; and Project Amber, which Oracle describes as a project to “explore and incubate smaller, productivity-oriented Java language features that have been accepted as candidate JEPs.”

One of the Project Loom additions in this release is virtual threads, which Georges Saab, senior vice president of development for the Java Platform at Oracle and OpenJDK Chair, describes as being one of the most influential preview features in this release. Virtual threads are “lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications,” as defined in the JEP listing for this feature.

“We’re really excited with how this has come out because it just takes Java scalability to an entirely new level, while not breaking your existing programs,” Saab told SD Times. “And this is something that not only people in the Java space are excited about; we’ve seen people across the industry, even people involved in other language platforms looking at this and saying, ‘Wow, Java really did it right here.’”

Project Loom also includes two preview features: scoped values and structured concurrency. Scoped values are “values that may be safely and efficiently shared to methods without using method parameters,” according to Oracle. Structured concurrency treats groups of related tasks from multiple threads as a single unit, which helps streamline error handling and improve reliability. 

Another major update in this release not tied to a particular named project is the final version of generational ZGC, otherwise known as the Z Garbage Collector. Generational ZGC separates young and old objects so that young objects can be collected more frequently. Some of the benefits of this include lower risk of allocation stalls, lower required heap memory overhead, and lower garbage collection CPU overload. 

Several updates in Java 21 come from Project Amber, such as pattern matching for switch expressions, which allows an expression to be tested against a number of different patterns. This helps data-oriented queries to be expressed more concisely and safely. 

Also from Project Amber are unnamed patterns and variables, and unnamed classes and instance main methods, both of which are in preview. These are directed at making Java more approachable, Saab explained.

“Someone did a study at one point and looked at the ‘Hello World!’ program in Java and noted that you really kind of have to learn about 32 concepts of object-oriented programming in order to get started,” Saab explained. “And we thought that was too many. We thought that in this day and age, we want something that is easier for students to get their heads around, while at the same time, making sure that there’s a very gradual and graceful on-ramp into writing more sophisticated Java programs, and learning the rest of those concepts.”

Other Project Amber features include Record Patterns, which deconstruct record values, and a preview for String Templates, which combines literal text to embedded expressions and template processors.

“As a developer myself, I get really excited about Project Amber and all of the progress it’s made over the last couple of years, including this release, things like record patterns, and records themselves, and pattern matching. All of these things are designed to work very, very nicely together,” said Chad Arimura, vice president of Java Developer Relations at Oracle. 

Coming out of Project Panama are updates to two APIs that are being worked on: the Foreign Function & Memory API (currently in its third preview) and the Vector API (currently in its sixth incubator). 

The Foreign Function & Memory API allows “Java programs to interoperate with code and data outside of the Java runtime.” The Vector API expresses “vector computations that reliably compile at runtime to optimal vector instructions on supported CPU architectures.”

Other new features in this release include Sequenced Collections, Key Encapsulation Mechanism API, deprecation of the 32-bit x86 port, and preparation for disallowing the dynamic loading of agents

“We’re quite pleased with where Java is right now, and couldn’t be more pleased with the innovation pipeline that we have,” said Saab.

 

The post Java 21 adds virtual threads preview and generational ZGC appeared first on SD Times.



from SD Times https://ift.tt/cWA6Jbg

Comments

Popular posts from this blog

Difference between Web Designer and Web Developer Neeraj Mishra The Crazy Programmer

Have you ever wondered about the distinctions between web developers’ and web designers’ duties and obligations? You’re not alone! Many people have trouble distinguishing between these two. Although they collaborate to publish new websites on the internet, web developers and web designers play very different roles. To put these job possibilities into perspective, consider the construction of a house. To create a vision for the house, including the visual components, the space planning and layout, the materials, and the overall appearance and sense of the space, you need an architect. That said, to translate an idea into a building, you need construction professionals to take those architectural drawings and put them into practice. Image Source In a similar vein, web development and design work together to create websites. Let’s examine the major responsibilities and distinctions between web developers and web designers. Let’s get going, shall we? What Does a Web Designer Do?

A guide to data integration tools

CData Software is a leader in data access and connectivity solutions. It specializes in the development of data drivers and data access technologies for real-time access to online or on-premise applications, databases and web APIs. The company is focused on bringing data connectivity capabilities natively into tools organizations already use. It also features ETL/ELT solutions, enterprise connectors, and data visualization. Matillion ’s data transformation software empowers customers to extract data from a wide number of sources, load it into their chosen cloud data warehouse (CDW) and transform that data from its siloed source state, into analytics-ready insights – prepared for advanced analytics, machine learning, and artificial intelligence use cases. Only Matillion is purpose-built for Snowflake, Amazon Redshift, Google BigQuery, and Microsoft Azure, enabling businesses to achieve new levels of simplicity, speed, scale, and savings. Trusted by companies of all sizes to meet

2022: The year of hybrid work

Remote work was once considered a luxury to many, but in 2020, it became a necessity for a large portion of the workforce, as the scary and unknown COVID-19 virus sickened and even took the lives of so many people around the world.  Some workers were able to thrive in a remote setting, while others felt isolated and struggled to keep up a balance between their work and home lives. Last year saw the availability of life-saving vaccines, so companies were able to start having the conversation about what to do next. Should they keep everyone remote? Should they go back to working in the office full time? Or should they do something in between? Enter hybrid work, which offers a mix of the two. A Fall 2021 study conducted by Google revealed that over 75% of survey respondents expect hybrid work to become a standard practice within their organization within the next three years.  Thus, two years after the world abruptly shifted to widespread adoption of remote work, we are declaring 20