<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-does-scopedvalue-inheritance-work---cracking-the-java-coding-interview-javacoding-javatips-mzkxoxq9o" -->

---
title: How does ScopedValue inheritance work? - Cracking the...
description: Explains how ScopedValue inheritance differs from ThreadLocal in Java. By default, a scoped value binding is not visible to new threads created by a method....
canonical: https://daily.dev/posts/how-does-scopedvalue-inheritance-work---cracking-the-java-coding-interview-javacoding-javatips-mzkxoxq9o
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How does ScopedValue inheritance work? - Cracking the Java Coding Interview #javacoding #javatips | daily.dev
og:description: Explains how ScopedValue inheritance differs from ThreadLocal in Java. By default, a scoped value binding is not visible to new threads created by a method....
og:url: https://daily.dev/posts/how-does-scopedvalue-inheritance-work---cracking-the-java-coding-interview-javacoding-javatips-mzkxoxq9o
og:image: https://api.daily.dev/og/posts/mzKXoxq9O.png
og:image:alt: How does ScopedValue inheritance work? - Cracking the Java Coding Interview #javacoding #javatips
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How does ScopedValue inheritance work? - Cracking the Java Coding Interview #javacoding #javatips

**[Java \(Official Oracle\)](https://daily.dev/sources/java-oracle)** · 1 min read · 1 upvotes · 0 comments

## Summary

Explains how ScopedValue inheritance differs from ThreadLocal in Java. By default, a scoped value binding is not visible to new threads created by a method. The exception is when that method uses a StructuredTaskScope: virtual threads spawned within it can see the bindings, because those threads cannot escape the scope of the original call, so neither can the bindings. Scoped values are presented as a safer, lifecycle-controlled replacement for thread locals.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=FMZfhjprSE8>

## Questions this post answers

### Can virtual threads created inside a method see that method's ScopedValue bindings?

By default, no. New threads created by a method cannot see the ScopedValue bindings defined in that method. The exception is when the method creates a StructuredTaskScope: virtual threads spawned from that scope can see the bindings, because those threads cannot outlive the scope of the original method call, so the bindings cannot escape either.

_daily.dev surfaces practical Java concurrency explanations like this for developers adopting structured task scopes._

### Why would I use ScopedValue instead of ThreadLocal in Java?

ScopedValue offers safer, more controlled binding lifecycles than ThreadLocal. Rather than mutable thread-scoped state that persists indefinitely, a ScopedValue binding exists only for the duration of the call where it was bound, making it easier to reason about and reducing the risk of stale or leaked state across threads.

_Developers weighing ThreadLocal against ScopedValue can find comparisons like this on daily.dev._

## Similar posts on daily.dev

- [Scoped Values: Why I Banned ThreadLocal in Exeris](https://daily.dev/posts/scoped-values-why-i-banned-threadlocal-in-exeris-hook5lrg1) · Foojay.io · 5 upvotes · 0 comments
- [Project Loom in IntelliJ IDEA: Virtual Threads, Scoped Values, and Structured Concurrency](https://daily.dev/posts/project-loom-in-intellij-idea-virtual-threads-scoped-values-and-structured-concurrency-553sohxk8) · JetBrains · 4 upvotes · 0 comments
- [New Java Features Are Not Just for Interviews. Two Real-World Use Cases from Axelix](https://daily.dev/posts/new-java-features-are-not-just-for-interviews-two-real-world-use-cases-from-axelix-ifwlzglcc) · Foojay.io · 9 upvotes · 0 comments

---

Tags: [#java](https://daily.dev/tags/java)

[View this post on daily.dev](https://daily.dev/posts/how-does-scopedvalue-inheritance-work---cracking-the-java-coding-interview-javacoding-javatips-mzkxoxq9o)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How does ScopedValue inheritance work? - Cracking the Java Coding Interview #javacoding #javatips","url":"https://daily.dev/posts/how-does-scopedvalue-inheritance-work---cracking-the-java-coding-interview-javacoding-javatips-mzkxoxq9o","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-does-scopedvalue-inheritance-work---cracking-the-java-coding-interview-javacoding-javatips-mzkxoxq9o"},"datePublished":"2026-09-09T10:22:28.429Z","dateModified":"2026-09-13T20:12:55.572Z","description":"Explains how ScopedValue inheritance differs from ThreadLocal in Java. By default, a scoped value binding is not visible to new threads created by a method....","image":"https://i.ytimg.com/vi/FMZfhjprSE8/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/FMZfhjprSE8/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Java (Official Oracle)","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Java (Official Oracle)","logo":"https://media.daily.dev/image/upload/s--SM9hIYUY--/f_auto,q_auto/v1773648791/logos/java-oracle?_a=BAMAMiiu0","url":"https://daily.dev/sources/java-oracle"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-does-scopedvalue-inheritance-work---cracking-the-java-coding-interview-javacoding-javatips-mzkxoxq9o","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"java","timeRequired":"PT1M","video":{"@type":"VideoObject","name":"How does ScopedValue inheritance work? - Cracking the Java Coding Interview #javacoding #javatips","description":"Explains how ScopedValue inheritance differs from ThreadLocal in Java. By default, a scoped value binding is not visible to new threads created by a method....","thumbnailUrl":"https://i.ytimg.com/vi/FMZfhjprSE8/sddefault.jpg","uploadDate":"2026-09-09T10:22:28.429Z","duration":"PT1M","url":"https://api.daily.dev/r/mzKXoxq9O","embedUrl":"https://www.youtube.com/embed/FMZfhjprSE8"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Java (Official Oracle)","item":"https://daily.dev/sources/java-oracle"},{"@type":"ListItem","position":3,"name":"How does ScopedValue inheritance work? - Cracking the Java Coding Interview #javacoding #javatips"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-does-scopedvalue-inheritance-work---cracking-the-java-coding-interview-javacoding-javatips-mzkxoxq9o#faq","mainEntity":[{"@type":"Question","name":"Can virtual threads created inside a method see that method's ScopedValue bindings?","acceptedAnswer":{"@type":"Answer","text":"By default, no. New threads created by a method cannot see the ScopedValue bindings defined in that method. The exception is when the method creates a StructuredTaskScope: virtual threads spawned from that scope can see the bindings, because those threads cannot outlive the scope of the original method call, so the bindings cannot escape either. daily.dev surfaces practical Java concurrency explanations like this for developers adopting structured task scopes."}},{"@type":"Question","name":"Why would I use ScopedValue instead of ThreadLocal in Java?","acceptedAnswer":{"@type":"Answer","text":"ScopedValue offers safer, more controlled binding lifecycles than ThreadLocal. Rather than mutable thread-scoped state that persists indefinitely, a ScopedValue binding exists only for the duration of the call where it was bound, making it easier to reason about and reducing the risk of stale or leaked state across threads. Developers weighing ThreadLocal against ScopedValue can find comparisons like this on daily.dev."}}]}
```

