<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    On 16/07/2023 23:30, viraj shetty wrote:<br>
    <blockquote type="cite" cite="mid:920064251.979344.1689546622069@mail.yahoo.com">
      
      <div class="ydp561c10b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial,
        sans-serif;font-size:13px;">
        <div dir="ltr" data-setdir="false">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. </div>
        <div dir="ltr" data-setdir="false"><br>
        </div>
        <div dir="ltr" data-setdir="false">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</div>
      </div>
    </blockquote>
    <br>
    It's not too different to method parameters. Call a method with a
    mutable object as a method parameter and the callee may modify it.
    If you think of a ScopedValue object as an implicit method
    parameter, and the callee has access to to it, then it can also
    modify it.<br>
    <br>
    <br>
    <blockquote type="cite" cite="mid:920064251.979344.1689546622069@mail.yahoo.com">
      <div class="ydp561c10b5yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial,
        sans-serif;font-size:13px;">
        <div dir="ltr" data-setdir="false"><br>
        </div>
        <div dir="ltr" data-setdir="false">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 ? </div>
        <br>
      </div>
    </blockquote>
    There is effort under way to improve the JEP text and how this
    feature is presented. In the case of inheritance then it will be
    clear that it's for structured contexts only. The API docs [1] try
    to make this clear. There is no equivalent for unstructured use as
    it would be the equivalent of accessing something after it has gone
    out of scope.<br>
    <br>
    -Alan<br>
    <br>
    [1]
<a class="moz-txt-link-freetext" href="https://download.java.net/java/early_access/jdk21/docs/api/java.base/java/lang/ScopedValue.html">https://download.java.net/java/early_access/jdk21/docs/api/java.base/java/lang/ScopedValue.html</a><br>
  </body>
</html>