Skip to content

Commit 44f32bf

Browse files
committed
starter Java 19
1 parent 591eab0 commit 44f32bf

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ A project to explore more about the new features of Java 8, 9, ...
1010

1111
## Resume by Version
1212

13+
* [Java 19](java-19/)
14+
* Virtual Thread :rocket:
15+
* Pattern matching for `switch` (preview 3)
16+
* Vector API (fourth incubator)
17+
1318
* [Java 18](java-18/)
1419
* UTF-8 by Default
1520
* Simple Web Server
@@ -31,8 +36,8 @@ A project to explore more about the new features of Java 8, 9, ...
3136
* Unix-Domain Socket Channels
3237
* Warnings for Value-Based Classes
3338
* Foreign-Memory Access API (incubator)
34-
* Vector API (Incubator)
35-
* Foreign Linker API (Incubator)
39+
* Vector API (incubator)
40+
* Foreign Linker API (incubator)
3641
* Packaging Tool
3742

3843
* [Java 15](java-15/) (Sep, 2020)

java-19/README.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Java 18
2+
3+
To run each example use: `java --enable-preview --source 18 <FileName.java>`
4+
5+
## Features
6+
7+
### Language
8+
9+
* Pattern matching for `switch`
10+
* Minor improvements from JDK 18:
11+
* changed guarded pattern from `&&` to `when` keyword
12+
* definition: guard is the boolean expression, guarded pattern is the case with guard
13+
* guarded pattern: `case Hero h when h.getCity() == Cities.NEW_YORK`
14+
* guard: `h.getCity() == Cities.NEW_YORK`
15+
* Virtual Threads (user-mode threads)
16+
* `Virtual threads are lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications`
17+
* definitions:
18+
* virtual thread is an instance of `java.lang.Thread` that is not tied to a particular OS thread, only consumes an OS thread only while it performs calculations on the CPU;
19+
* platform thread is an instance of `java.lang.Thread` implemented a thin wrapper around an OS thread.
20+
* blocking:
21+
* `when code running in a virtual thread calls a blocking I/O operation in the java.* API, the runtime performs a non-blocking OS call and automatically suspends the virtual thread until it can be resumed later`;
22+
* `virtual threads preserve the reliable thread-per-request style that is harmonious with the design of the Java Platform while utilizing the hardware optimally`
23+
* virtual threads employ M:N scheduling, where a large number (M) of virtual threads is scheduled to run on a smaller number (N) of OS threads.
24+
* `Virtual threads are not faster threads — they do not run code any faster than platform threads. They exist to provide scale (higher throughput), not speed (lower latency). There can be many more of them than platform threads, so they enable the higher concurrency needed for higher throughput according to Little's Law.`
25+
* scenarios where it can significantly improve throughput when:
26+
* number of concurrent tasks is high, and
27+
* work is not CPU-bound.
28+
* support thread-local variables and interruption
29+
* more notes about Project Loom [here](../java-loom/)
30+
* we can use `Executors.newVirtualThreadPerTaskExecutor` to create virtual threads
31+
32+
## JEPs
33+
34+
* [422](https://openjdk.java.net/jeps/422) - Linux/RISC-V Port
35+
* [424](https://openjdk.java.net/jeps/424) - Foreign Function & Memory API (Preview)
36+
* [425](https://openjdk.java.net/jeps/425) - Virtual Threads (Preview)
37+
* [426](https://openjdk.java.net/jeps/426) - Vector API (Fourth Incubator)
38+
* [427](https://openjdk.java.net/jeps/427) - Pattern Matching for switch (Third Preview)
39+
40+
## Links
41+
42+
* [JDK 19 Jeps](https://openjdk.java.net/projects/jdk/19/)

java-loom/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ About the API:
3131

3232
> [...] we learned during that experiment — that we can keep parts of the Thread API and de-emphasize others — moved the needle in favor of keeping the existing API, and representing our user-mode threads with the Thread class. And here we are: virtual threads are just Threads, and any library that knows Thread already knows virtual threads.
3333
34-
Abount concurrent access:
34+
About concurrent access:
3535

3636
> [...] how do we limit concurrent access to some service? Instead of breaking the task down and running the service-call subtask in a separate, constrained pool, we just let the entire task run start-to-finish, in its own thread, and use a semaphore in the service-call code to limit concurrency — this is how it should be done.
3737

0 commit comments

Comments
 (0)