Overview
Syllabus
Intro
Why Virtual Threads have been added?
Analyzing the CPU usage of your blocking code
Why the "one request per thread" model cannot work
Solving this problem: less expensive threads or asynchronous code?
Introducing the asynchronous solution
Writing an imperative, blocking online shopping example
Making this code asynchronous the CompletableFuture API
Issues with the asynchronous code: debugging, testing, stack trace, exception handling, timeout handling
Making threads less expensive: by how much?
Creating and using virtual threads
How Virtual Threads are working under the hood
Running blocking code in a virtual thread
Handling native code and synchronized blocks: avoid pinning virtual threads
Wrapping up: virtual threads are cheap, blocking them is fine
Outro
Taught by
Java