[HN Gopher] JEP 506: Scoped Values final for Java 25
       ___________________________________________________________________
        
       JEP 506: Scoped Values final for Java 25
        
       Author : ludovicianul
       Score  : 30 points
       Date   : 2025-04-15 11:17 UTC (11 hours ago)
        
 (HTM) web link (openjdk.org)
 (TXT) w3m dump (openjdk.org)
        
       | skerit wrote:
       | Interesting proposal, I can see myself using this.
        
       | djenndhxhd wrote:
       | Tramp parameters are a common occurrence, if not avoided with
       | care.
       | 
       | I see value in this proposal
        
       | Pet_Ant wrote:
       | So it sort of looks like a DSL for a variant of ThreadLocal that
       | gives you an idea of the lifeline of variable instead of just
       | being global. Apparently with virtual threads they are expecting
       | an increase in the number of running (virtual) threads several
       | orders of magnitude larger than what was previously seen and that
       | with ThreadLocals would just be too much.
       | 
       | So the have added this:
       | 
       | > ScopedVaule.where(CONTEXT, context).run(() ->
       | Application.handle(request, response));
       | 
       | Which stores the object referenced by `context` to the
       | ScopedValue container `CONTEXT` ^ for the duration of the thread
       | running `Application.handle(request,response)`.
       | 
       | Not really sexy, but I understand how you might really benefit if
       | you are processing lots of data, but for most enterprise CRUD
       | apps this seems inapplicable.
       | 
       | ^ I think this a "monad"? I'm not a functional programmer.
        
       ___________________________________________________________________
       (page generated 2025-04-15 23:02 UTC)