A few questions on ScopedValue

viraj shetty shetty_viraj at yahoo.com
Sun Jul 16 22:30:22 UTC 2023


I have read JEP 446 related to Scoped Values and have been playing with it using Java 21 early release. I have couple of minor questions/clarifications. 
1. The JEP seems to convey the idea that the ScopeValue objects are one way communication down the call chain. But the scoped value can be an object which is mutable and it could be modified deep inside the call stack. Effectively that is two way communication - even though the variable itself cannot be modified. Not a big deal but maybe a clarification is useful
2. It also conveyed the idea that scoped values are automatically available for Child Threads. But on playing with it, its available only for child threads of StructuredTaskScope, not for threads started with Thread.ofVirtual() or Executorservice.  Is this because its guaranteed that the threads submitted in structuredTaskScope ends before ScopedValue scope ends ? Making it bounded is the idea ? 
Thanks for the phenomenal work.~ Viraj 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230716/43a852e5/attachment.htm>


More information about the loom-dev mailing list