JDK 21 GA: All New Features, Virtual Threads & Generational ZGC Explained
The article introduces the official General Availability release of JDK 21, explains version naming conventions such as Alpha, Beta, RC, GA and LTS, and details its fifteen new features—including Virtual Threads, preview language enhancements, generational ZGC, and the removal of Shenandoah—while showing how to enable them.
JDK 21 has reached General Availability (GA), meaning it is the officially released, fully tested version.
GA stands for General Availability, indicating a production‑ready release.
Version naming conventions:
Alpha – internal testing, many bugs, not for external use.
Beta – public testing, major bugs fixed, still adding features.
Gamma – near‑final, minor changes before release candidate.
RC (Release Candidate) – feature‑complete, focused on bug fixing.
GA – final production version.
Release – final version, often shown with © symbol.
Stable – fully vetted open‑source release.
LTS (Long‑Term Support) versions receive extended maintenance and security updates; in Java, LTS releases include Java 8, 11, and 17.
JDK 21 introduces fifteen new features grouped into four JEP categories: core Java libraries, language specifications, HotSpot, and security libraries.
Key feature: JEP 444 – Virtual Threads, a lightweight concurrency model that can be adopted with minimal code changes.
To enable virtual threads, replace the thread‑pool creation with the following code:
Other notable features include:
Core library: JEP 431 (Sequence Collections), JEP 442 (Foreign Function & Memory API, third preview), JEP 444 (Virtual Threads), JEP 446 (Scoped Values, preview), JEP 448 (Vector API, sixth incubator), JEP 453 (Structured Concurrency, preview).
Language: JEP 430 (String Templates, preview), JEP 440 (Record Patterns), JEP 441 (Switch Pattern Matching), JEP 443 (Unnamed Patterns & Variables, preview), JEP 445 (Unnamed Classes & Main Method, preview).
HotSpot: JEP 439 (Generational ZGC), JEP 449 (Deprecate Windows x86 port), JEP 451 (Prohibit dynamic loading agents).
Security: JEP 452 (Key Encapsulation Mechanism API).
JEP 445 simplifies the classic “Hello, World!” program; the preview version can be compiled and run with:
javac --release 21 --enable-preview Main.java
java --enable-preview MainGenerational ZGC, introduced in JEP 439, adds a generational mode to the Z Garbage Collector, which is disabled by default and can be enabled via configuration.
Shenandoah was planned for JDK 21 but was delayed due to review risks; it is targeted for JDK 22.
Overall, JDK 21 brings significant improvements to concurrency, memory handling, and language ergonomics, offering developers a modern platform for production workloads.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Su San Talks Tech
Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
