Products
Features
YouTube Video Summarizer
Summarize YouTube videos
Web & PDF Highlighter
Highlight web pages & PDFs
Chat with PDF
Ask any PDF questions with AI
Ask AI Clone
Chat with your highlights & memories
Audio Transcriber
Transcribe audio files to text
Glasp Reader
Read and highlight articles
Kindle Highlight Export
Export your Kindle highlights
Idea Hatch
Hatch ideas from your highlights
Integrations
Obsidian Plugin
Notion Integration
Pocket Integration
Instapaper Integration
Medium Integration
Readwise Integration
Snipd Integration
Hypothesis Integration
Apps & Extensions
Chrome Extension
Safari Extension
Edge Add-ons
Firefox Add-ons
iOS App
Android App
Discover
Discover
Ideas
Discover new ideas and insights
Articles
Curated articles and insights
Books
Book recommendations by great minds
Posts
Essays and notes from readers
Quotes
Inspiring quotes collection
Videos
Curated videos and summaries
Explore Glasp
Glasp Newsletter
Weekly insights and updates
Glasp Talk
Interview series with great minds
Glasp Blog
Latest news and articles
Glasp Use Cases
Learn how others use Glasp
Build & Support
Glasp API
Access Glasp's API for developers
MCP Connector
Connect Glasp to Claude & ChatGPT
Community
Glasp Reddit Community
Students
Student discount and benefits
FAQs
Frequently Asked Questions
AboutPricing
DashboardLog inSign up

Continuations - Under the Covers

9.1K views
•
August 26, 2023
by
Java
YouTube video player
Continuations - Under the Covers

TL;DR

This video discusses the implementation of continuations in the HotSpot VM, focusing on their role in executing virtual threads efficiently and optimizing memory usage.

Transcript

uh good morning so uh today we're going to be talking a little bit about continuations and how we've implemented them in the hotspots VM so yesterday uh we heard about virtual trades I think by now everyone knows what virtual threats are these are threads that you can have lots of and they're implemented in user mode in the jdk now what does it mea... Read More

Key Insights

  • 🧵 Implementing virtual threads: Virtual threads are a combination of a continuation and a scheduler. The scheduler is written in Java, while the continuation part is implemented in the VM.
  • 🚀 Virtual threads and performance: Contrary to popular belief, virtual threads don't improve performance due to fast context switching. Instead, they improve throughput by allowing more threads to handle requests simultaneously, according to Little's law. ⏰ Efficient context switching: Virtual threads need to have efficient context switching, not in terms of latency but in terms of consuming minimal CPU time. This is necessary because both the continuation and scheduler components need to consume as little CPU as possible during context switches.
  • 🌐 Types of continuations: The JDK implements a non-reentrant delimited asymmetric multiprompt continuation. Continuations have a body (runnable) and a scope, which allows nesting continuations inside each other. The interface for continuation includes methods like run and yield.
  • 🔀 How continuations work: Continuations can suspend and resume themselves, allowing for the execution of code to be paused and picked up later. When run is called, yield returns, and when yield is called, run returns. This creates a back-and-forth flow of execution.
  • 💭 Terminology: When a continuation is running, it is "mounted" on a thread, and when it is suspended, it is "unmounted." A thread is a combination of a continuation and a scheduler.
  • 🛑 Blocking virtual threads: To block a virtual thread, the Java code calls the Park method, which blocks the thread until it is unblocked with the Unpark method. If the thread is virtual, it yields the continuation instead of suspending the whole thread, making it easier to switch between tasks efficiently.
  • 🧠 Memory optimization with stack chunks: Continuations in HotSpot JVM use a memory optimization technique called stack chunks. Stack chunks allow for efficient copying of frames between the thread stack and the continuation object. The copying process is nearly free as it happens within the cache.

Install to Summarize YouTube Videos and Get Transcripts

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: How do virtual threads improve throughput in server applications?

Virtual threads improve throughput in server applications by allowing for parallel execution of multiple requests, increasing the number of concurrent tasks that can be processed and resulting in higher overall throughput.

Q: Why is the efficiency of context switching important for virtual threads?

While virtual threads do not obtain performance benefits from fast context switching, efficient context switching is still crucial to ensure that virtual threads consume minimal CPU time, enabling a larger number of threads to be executed concurrently.

Q: What is the role of continuations in implementing virtual threads?

Continuations in the HotSpot VM allow for the suspension and resumption of the execution of virtual threads, providing efficient execution and enabling the implementation of features like blocking and yielding.

Q: How is memory usage optimized in the implementation of continuations?

The HotSpot VM utilizes a lazy copy approach, copying only the necessary frames and optimizing memory usage through compression techniques that reduce the memory footprint of virtual threads.

Q: What is the significance of the stack chunks in the implementation of continuations?

Stack chunks are a new type of object in the HotSpot VM that contain multiple frames and enable efficient copying of frames during continuation execution. The GC can compress stack chunks to further optimize memory usage.

Summary & Key Takeaways

  • The implementation of virtual threads in the HotSpot VM combines a continuation (implemented in the VM) and a scheduler (implemented in Java).

  • Virtual threads improve throughput in server applications but do not provide performance benefits from fast context switching.

  • Continuations are runnables that can suspend and later be resumed from the last suspended point, allowing for efficient execution and minimal CPU usage.

  • The HotSpot VM utilizes a lazy copy approach to minimize the overhead of copying frames and optimizes memory usage through compression techniques.


Read in Other Languages (beta)

English

Share This Summary 📚

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Explore More Summaries from Java 📚

How Does Java's G1 Garbage Collector Work? thumbnail
How Does Java's G1 Garbage Collector Work?
Java
How to Upgrade to Java 25 #RoadTo25 thumbnail
How to Upgrade to Java 25 #RoadTo25
Java
How Netflix Uses Java - 2025 Edition thumbnail
How Netflix Uses Java - 2025 Edition
Java
Fallacies of Software Development thumbnail
Fallacies of Software Development
Java
Modern Java Deep Dive thumbnail
Modern Java Deep Dive
Java

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Apps & Extensions

  • Chrome Extension
  • Safari Extension
  • Edge Add-ons
  • Firefox Add-ons
  • iOS App
  • Android App

Key Features

  • YouTube Video Summarizer
  • Web & PDF Summarizer
  • Web & PDF Highlighter
  • Chat with PDF
  • Ask AI Clone
  • Audio Transcriber
  • Glasp Reader
  • Kindle Highlight Export
  • Idea Hatch

Integrations

  • Obsidian Plugin
  • Notion Integration
  • Pocket Integration
  • Instapaper Integration
  • Medium Integration
  • Readwise Integration
  • Snipd Integration
  • Hypothesis Integration

More Features

  • APIs
  • MCP Connector
  • Blog & Post
  • Embed Links
  • Image Highlight
  • Personality Test
  • Quote Shots

Company

  • About us
  • Blog
  • Community
  • FAQs
  • Job Board
  • Newsletter
  • Pricing
Terms

•

Privacy

•

Guidelines

© 2026 Glasp Inc. All rights reserved.