Native methods and virtual threads

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Jul 13 16:06:25 UTC 2023


This seems like a potentially nice suggestion. CC'ing loom-dev.

Maurizio

On 13/07/2023 17:04, Brian S O'Neill wrote:
> In my project, I depend heavily on native methods which perform file 
> I/O. These operations might block the current thread, but this isn't a 
> concern, and in some cases, blocking is desirable. With virtual 
> threads, I am concerned. I don't want to have to rewrite all my code 
> to workaround any potential issues.
>
> Inside the JDK, any calls which might block inside native code use the 
> internal Blocker class to help ensure that virtual threads aren't 
> starved of carrier threads. This class is internal, and I think it 
> should stay that way. It's easy to be misused.
>
> However, if it were possible to indicate that a downcall handle might 
> block, it would be incredibly useful. This isn't likely to be misused 
> simply because it wouldn't be applicable to ordinary code.


More information about the panama-dev mailing list