Native methods and virtual threads
Brian S O'Neill
bronee at gmail.com
Thu Jul 13 16:04:12 UTC 2023
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