MENU

Fun & Interesting

Scoped Values in Java 22

Will Tollefson 1,346 1 year ago
Video Not Working? Fix It Now

In this video we'll cover SCOPED VALUES IN JDK 22. We'll talk about what a ScopedValue gets you vs prior ThreadLocal code examples and why you should probably migrate to ScopedValue especially int the context of virtual threads and structured concurrency. Scoped values address some of the main problems with ThreadLocal such as UNCONSTRAINED MUTABILITY, UNBOUNDED LIFETIMES, and EXPENSIVE INHERITANCE. I'm Will Tollefson, a guy who loves to NEVER STOP LEARNING and teach others what I've learned. If you're enjoying the content, please LIKE, SUBSCRIBE, and SHARE! LINKS: JEP 464: https://openjdk.org/jeps/464 VIDEO CHAPTERS: 0:00 Introduction 0:55 ThreadLocal Review 3:22 ThreadLocal Problems 5:22 Migrating to ScopedValue 8:59 The Benefits of ScopedValue 11:50 Pros and Cons of ScopedValue 16:42 Closing Thoughts

Comment