Continuations: The magic behind virtual threads in Java
summary
Explains how Java 21 virtual threads use continuations to pause and resume execution, showing the actual API calls Continuation.doYield/doRun and constructing continuations with new Continuation(scope, runnable); builds a toy scheduler using ExecutorService and ScopedValues, simulates blocking with a Timer, and implements a simple VirtualThread class. Demonstrates performance: 2,000 virtual threads on 10 platform threads finish quickly while a plain platform-thread version runs far longer. Notes continuations remain internal to the JDK for now.
AI-written summary · about
chapters (10)
- 0:00Introduction to talk
- 1:51Virtual threads overview
- 5:03Creating virtual threads
- 8:04Understanding continuations
- 10:14Continuation API demo
- 15:29Stack management mechanics
- 18:02Generators with continuations
- 19:40Implementing the generator
- 25:42Building virtual threads
- 44:22Summary and Q&A
related talks
46mContinuations: The magic behind virtual threads in Java
49mEven threads are now virtual:past, present, future of concurrency in Java.
01h 00mAsynchronous Programming in Java using Virtual Threads
38mIntroduction and pitfalls of Java's new concurrency model
51mIntroduction and Pitfalls of Java's New Concurrency Model
38mIntroduction and pitfalls of Java's new concurrency model
45mIntroduction and pitfalls of virtual threads
53mVirtual Threads: Ushering in a New Era of Concurrency
