Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Java 21 New Feature - Virtual Threads

Java via YouTube

Overview

Google, IBM & Meta Certificates – 40% Off
One Coursera Plus subscription covers most Professional Certificates on Coursera.
Unlock All Certificates
This course explains how to use Java 21 virtual threads and how they work under the hood. It compares them with asynchronous programming and covers blocking code, native calls, and synchronized blocks that can pin virtual threads.

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

Reviews

Start your review of Java 21 New Feature - Virtual Threads

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.