Java 18
JEP 408: Simple Web Server (opens in a new tab)
By default, the server runs in the foreground and binds to the loopback address (127.0.0.1) and port 8000.
# Under the directory to be served
jwebserver -p $portJEP 420: Pattern Matching for switch (Second Preview) (opens in a new tab)
Java 19
JEP 427: Pattern Matching for switch (Third Preview) (opens in a new tab)
Java 21
- OpenJDK - JDK 21 (opens in a new tab)
- Oracle Blog - Java Blog - The Arrival of Java 21 (opens in a new tab)
JEP 430: String Templates (Preview) (opens in a new tab)
JEP 431: Sequenced Collections (opens in a new tab)
JEP 439: Generational ZGC (opens in a new tab)
JEP 442: Foreign Function & Memory API (Third Preview) (opens in a new tab)
JEP 444: Virtual Threads (opens in a new tab)
-
Oracle - Java SE - 21 - Core Libraries - 14 Concurrency - Virtual Threads (opens in a new tab)
Virtual threadscan significantly improve thethroughput—not the latency—of servers written in thethread-per-requeststyle. In this style, the server dedicates a thread to processing each incoming request for its entire duration.-
How to use
-
Write Simple, Synchronous Code Employing Blocking I/O APIs in the
Thread-Per-RequestStyle -
Represent Every Concurrent Task as a
Virtual Thread; Never PoolVirtual Threads -
Use
Semaphoresto Limit Concurrency -
Don't Cache Expensive Reusable Objects in Thread-Local Variables
Use
Scoped Valuesas a modern alternative tothread-localvariables. -
Avoid Lengthy and Frequent Pinning
-
-