~/talk

Virtual Threads: Taming the Wild Multithreading Beast

Talkat JNation 2024 · 2024-06-04..06-05· [java, concurrency]
slides:none on file

Shows that Java 21 virtual threads let code create many cheap threads using startVirtualThread and newVirtualThreadPerTaskExecutor; a demo spawns 100,000 threads sleeping 1s to prove platform threads hit OOM while virtual threads survive. Benchmarks: virtual threads hit ~840 req/s on a no-delay endpoint vs ~38 for platform threads, but drop to ~547 vs 124 when each request forces unmounting, revealing mounting/unmounting overhead and pinning from synchronized or native calls. Structured concurrency scopes (shutdown-on-success/failure) simplify cancelling and joining child tasks.

AI-written summary · about

  1. 0:00Introduction to virtual threads
  2. 5:14Virtual vs platform threads
  3. 7:27Creating virtual threads
  4. 11:30How virtual threads work
  5. 14:41When virtual threads fail
  6. 19:41Thread pinning issues
  7. 22:53Designing with virtual threads
  8. 26:26Structured concurrency
  9. 34:07Key takeaways and Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.