Hands-on Lab180min
Using Structured Concurrency and Scoped Values to Create a Virtual Threads Based Asynchronous Application
A hands-on lab on Project Loom’s virtual threads, structured concurrency, and scoped values. It teaches building a scalable web app, parallelizing requests, passing sensitive data safely, and comparing Loom’s thread-per-request approach with reactive programming for similar throughput.
talk.summaryAiDisclaimer
Ana-Maria MihalceanuOracle
José PaumardOracle
talkDetail.whenAndWhere
Monday, October 5, 13:30-16:30
TBA 7
talks.roomOccupancytalks.noOccupancyInfo
The Loom project is about making asynchronous programming simpler. The promise is to enable the "simple thread-per-request style to scale with near-optimal hardware utilization". Before virtual threads, this was only achievable with callback-based reactive programming. Loom first brought virtual thread in JDK 21 that makes the blocking of threads almost free. Along with it, it published the Scoped Values API in JDK 25, as a replacement of the Thread Local API. The last element is the Structured Concurrency API, which is still a preview feature in JDK 26 and 27. This hands-on lab guides you through writing a virtual thread-based web application that utilizes structured concurrency to parallelize requests, and implements different strategies to process them. Then it shows you how you can use scoped values to pass sensitive information from one module of your application to another one, without relying on method parameters. It also uses the principles of Data Oriented Programming to organize your application in a simple way. You will use StructuredTaskScopes, the implementations of the Joiner interface that the API gives you, and you will create your own implementations as well. In the end, you will see the patterns of code that the Loom project gives you to achieve the same throughput as a classical reactive application, and you will then be able to compare both approaches to choose which one you prefer.
Ana-Maria Mihalceanu
Ana is a Java Champion Alumni and Senior Developer Advocate for the Java Platform Group at Oracle, with an extensive background in Java and cloud development. More recently, her work has expanded to explore how machine learning and AI can be applied within the Java ecosystem, helping Java developers adopt emerging capabilities while continuing to benefit from the stability, tooling, and performance of the Java Platform. She actively supports the growth of technical communities through knowledge sharing and enjoys curating content for conferences as a program committee member.
José Paumard
José is a Java Developer Advocate at Oracle. He holds a PhD in applied mathematics and computer science and is a Java Champion alumnus. He has been an assistant professor at the University Sorbonne Paris Nord for 25 years. He is an active member of the Paris Java User Group, and a disorganizer of the JChateau unconference. He contributes Java learning content on the dev.java website. He publishes "Java Coding Tips", a biweekly series of shorts, and the "JEP Café", a video series, both on the Java YouTube channel.