Re: 回复: 回复: Avoid Native Pin when use Continuation direclty with reflection invoke(Internet mail)

Alan Bateman Alan.Bateman at oracle.com
Wed Nov 11 21:00:17 UTC 2020


On 11/11/2020 14:14, kalinshi(施慧) wrote:
>
> >As for your need to declare data to be local (with ThreadLocal) and 
> then share it globally, can you explain what it is that you’re trying 
> to do?
>
> For ThreadLocal on carrier thread, we want all VirtualThreads running 
> on it can access and update this carrier thread’s ThreadLocal.
>
> This carrier ThreadLocal can hold shared 
> configurations/stats/resources used by all VirtualThreads running on 
> same carrier thread.
>
> It’s not suppose “share it globally,” share it between all 
> VirtualThreads on same carrier thread.
>
>
We don't want to expose access to the carrier thread's locals as it 
could lead to all manner of breakage. There are number of discussion on 
this topic already in the mail archive,

If you use a custom scheduler, as Ron suggested, then you get a "hook" 
to run code on the carrier thread before and after the virtual thread 
task. The hook has a reference to the virtual thread so you may have 
enough for what you are doing.

-Alan


More information about the loom-dev mailing list