<html><head></head><body><div class="ydpe358c828yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div><div dir="ltr" data-setdir="false">Thanks for the clarification. </div><div dir="ltr" data-setdir="false"><br></div><div><br></div><div class="ydpe358c828signature"><div> </div></div></div>
<div><br></div><div><br></div>
</div><div id="yahoo_quoted_0198065409" class="yahoo_quoted">
<div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
<div>
On Sunday, July 16, 2023 at 06:58:50 PM EDT, Holo The Sage Wolf <holo3146@gmail.com> wrote:
</div>
<div><br></div>
<div><br></div>
<div><div id="yiv4701224092"><div><div><div>1) passing a mutable object to a ScopedValue does not give you upcall communication, it let you downcall an object that connects to a different place. If I would make an analogy: if I drop down from the 3rd floor a phone down to you, you can use the phone I dropped down to call me, but you can't throw stuff up to me.</div><div><br clear="none"></div><div>If you consider this an upwards communication then there is literally no such thing as one direction communication because I can always send you a file location and than you can send me messages from that file. (Maybe you can achieve true one direction communication using some kind of closed world sandboxes that don't expose anything to the outside world, but that would be useless)</div><div><br clear="none"></div><div><br clear="none"></div><div>2) yes, ScopedValues guarantee their integrity, outside of their scope they are not accessible.</div><div><br clear="none"></div><div>If their value was inherited you could do stuff like (exception omitted for clarity):</div><div><br clear="none"></div><div>ScopedValue.where(SECRET, "o7")</div><div> .run(() -> Thread.ofVirtual(() -> {</div><div> Thread.sleep(5000); </div><div> System.out.println("your secret is: " + SECRET.get());</div><div> }));</div><div>System.out.println("your secret is lost");</div><div><br clear="none"></div><div>Which would print:</div><div><br clear="none"></div><div>> your secret is lost</div><div>> your secret is: o7</div><div id="yiv4701224092yqt59536" class="yiv4701224092yqt0458860617"><div><br clear="none"><div class="yiv4701224092gmail_quote"><div dir="ltr" class="yiv4701224092gmail_attr">On Mon, Jul 17, 2023, 01:30 viraj shetty <<a rel="nofollow noopener noreferrer" shape="rect" ymailto="mailto:shetty_viraj@yahoo.com" target="_blank" href="mailto:shetty_viraj@yahoo.com">shetty_viraj@yahoo.com</a>> wrote:<br clear="none"></div><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;" class="yiv4701224092gmail_quote"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir="ltr">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"><br clear="none"></div><div dir="ltr">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 dir="ltr"><br clear="none"></div><div dir="ltr">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><div dir="ltr"><br clear="none"></div><div dir="ltr">Thanks for the phenomenal work.</div><div dir="ltr">~ Viraj </div><div><br clear="none"></div><div><div> </div></div></div></div></blockquote></div></div></div></div>
</div></div></div>
</div>
</div></body></html>