ScopedValue structured forking/forwarding API

Alan Bateman alan.bateman at oracle.com
Tue Jul 15 06:15:54 UTC 2025


On 09/07/2025 16:54, Nikita Bobko wrote:
> I understand why you are asking, and yes, currentThread may change
> across suspension points. It's not a problem though in Kotlin Coroutines
> because we have our ways to carry arbitrary data over threads.
>
Having currentThread change in a thread of execution will break a lot of 
things. I'm thinking of unlock methods throwing 
IllegalMonitorStateException if there is a suspension point after 
calling into some Java code that acquires a lock. Same thing with 
closing a confined arena throwing WrongThreadException, and dozens of 
other parts of the system that make use of the current Thread or current 
thread ID. This is on top of all methods that may block and all the 
serviceability features/APIs that are also thread focused. So while the 
discussion here is on inheriting ScopedValues, it looks like it is 
dwarfed in comparison to all the issues that may arise when executing 
Java code.

-Alan



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20250715/f108c77e/attachment.htm>


More information about the loom-dev mailing list