Scoped variables are a great example! There’s a similar concept in some 
reactive streams APIs (which is also a standard Java API starting in 9) with 
“contexts”, and the same concept is also available in the standard Go library 
in its “context” package for associating arbitrary values with string keys.
—
Matt Sicker

> On Sep 9, 2022, at 02:00, Volkan Yazıcı <vol...@yazi.ci> wrote:
> 
> I expect scoped variables that will be introduced with Loom to replace MDC
> attached to threads.
> 
> On Wed, Sep 7, 2022 at 8:41 PM Matt Sicker <boa...@gmail.com> wrote:
> 
>> Java 19 is coming out soon, and that includes a preview version of virtual
>> threads and structured concurrency APIs. While I’m not that familiar with
>> the Java implementation, I’d imagine it’ll have some similarities with
>> Kotlin coroutines and other similar structured concurrency libraries.
>> 
>> I’ve played around with the general concept myself, particularly an
>> interesting Python library for the same. I think some sort of structured
>> concurrency architecture would be useful for making some async aspects of
>> Log4j easier to understand (mostly the areas where we spawn threads for
>> things, not for async logging). While the API isn’t stable, we can abstract
>> it well enough with multi version jars. What I’m more curious about is how
>> we’d interact (if at all) with virtual threads, coroutines, or structured
>> concurrency APIs in general. If an app uses structured concurrency
>> throughout, it might want the logging system to participate in the same
>> flow for clean shutdowns.
>> 
>> Does anyone have any more concrete use cases that might be relevant for
>> us? Or does this seem more relevant for networking libraries and frameworks?
>> 
>> —
>> Matt Sicker

Reply via email to