Introduction and Pitfalls of Java's New Concurrency Model
Talkat JCON Europe 2023 · on Wednesday, 2023-06-21· at 14:00· Cinema 9, Im Mediapark 1, 50670 Köln, Germany·
summary
Java 20/21 adds virtual threads that create via startVirtualThread or by using newVirtualThreadPerTaskExecutor, and demonstrates structured concurrency with StructuredTaskScope and policies like shutdownOnSuccess to control lifetimes. Scoped values replace ThreadLocal with immutable, method-scoped bindings. Demos create 10k threads on a laptop and report ~100k+ virtual threads using ~225 MB while platform threads crash. Implementation uses carrier (platform) threads that mount/unmount virtual threads; pitfalls include pinned threads (synchronized, JNI, some filesystem calls), long CPU-only tasks, and libraries still relying on ThreadLocal.
AI-written summary · about
chapters (18)
- 0:00Introduction to Java's concurrency
- 2:07Current thread usage in Java
- 5:35Problems with executor services
- 5:55Async programming challenges
- 6:17Virtual threads overview
- 8:45Memory efficiency of virtual threads
- 9:06Demo: Creating virtual threads
- 13:46How virtual threads work
- 16:57Pitfalls of virtual threads
- 19:26Scoped values introduction
- 21:11Thread locals refresher
- 26:32Problems with thread locals
- 27:16Scoped values benefits
- 30:56Scoped values vs thread locals
- 32:02Structured concurrency explained
- 35:56Demo: Structured concurrency
- 42:00Getting started with virtual threads
- 42:53Q&A session
related talks
38mIntroduction and pitfalls of Java's new concurrency model
38mIntroduction and pitfalls of Java's new concurrency model
45mIntroduction and pitfalls of virtual threads
41mIntroduction and pitfalls of Java's new concurrency model
34mIntroduction and pitfalls of Java's new concurrency model
43mVirtual Threads: Taming the Wild Multithreading Beast
53mVirtual Threads: Ushering in a New Era of Concurrency
50mVirtual Threads, Structured Concurrency, Extent Locals: When to Use Them & How
