Рет қаралды 60,940
Learn about Virtual Threads, how to use them and how they are working under the hood, a new feature brought to you by the JDK 21.
Virtual Threads are one of the most anticipated and exciting new feature of the JDK 21. They are a new model of threads, much lighter than the traditional platform threads. Virtual Threads are there to address the complexity and maintenance costs of asynchronous programming, without giving up on the performances this model gives. With virtual threads, you can get the best throughput performances with simple imperative blocking code. This episode tells you all about it: it shows you how you can use them, and how Virtual Threads are working under the hood.
⎯⎯⎯⎯⎯⎯ Chapters ⎯⎯⎯⎯⎯⎯
0:00 Intro
0:36 Why Virtual Threads have been added?
1:54 Analyzing the CPU usage of your blocking code
3:24 Why the "one request per thread" model cannot work
5:59 Solving this problem: less expensive threads or asynchronous code?
6:50 Introducing the asynchronous solution
9:36 Writing an imperative, blocking online shopping example
12:01 Making this code asynchronous the CompletableFuture API
13:49 Issues with the asynchronous code: debugging, testing, stack trace, exception handling, timeout handling
17:05 Making threads less expensive: by how much?
18:57 Creating and using virtual threads
22:50 How Virtual Threads are working under the hood
26:51 Running blocking code in a virtual thread
29:01 Handling native code and synchronized blocks: avoid pinning virtual threads
31:25 Wrapping up: virtual threads are cheap, blocking them is fine
33:01 Outro
⎯⎯⎯⎯⎯⎯ Resources ⎯⎯⎯⎯⎯⎯
◦ All the videos of the #RoadTo21 series: • Road to 21
◦ Upgrading from Java 17 to 21 #RoadTo21: • How to Upgrade to Java...
◦ The JEP 444: Virtual Threads ➱ openjdk.org/je...
◦ JDD 2018: Reactive programming: lessons learned by Tomasz Nurkiewicz ➱ • JDD 2018: Reactive pro...
◦ Java Virtual Threads by Sergey Kuksenko ➱ inside.java/20...
◦ Helidon Níma & Virtual Threads by David Delabassee & Tomas Langer ➱ inside.java/20...
◦ Java Asynchronous Programming Full Tutorial with Loom and Structured Concurrency ➱ • Java Asynchronous Prog...
◦ Launching 10 millions virtual threads with Loom ➱ • Launching 10 millions ...
#Java21 #Update #Java #OpenJDK #InsideJava #RoadTo21 #VirtualThread #Loom