Project Loom VirtualThreads hang
Alan Bateman
Alan.Bateman at oracle.com
Fri Dec 30 08:24:18 UTC 2022
On 29/12/2022 22:25, robert engels wrote:
> I also found, Thread.onSpinWait().
>
> The default implementation is empty, but I wonder if there should be
> an implementation for VThreads that functions the same as
> Thread.yield()...
Thread.onSpinWait is for spin or busy waiting in low-level code, say
when spinning for some variable to change. It is compiled to a pause
instruction (or isb or the equivalent for the processor, maybe even a
nop) so it's measured in CPU cycles. This could be a different order of
magnitude to a Thread.yield that might be a few hundred nanoseconds in
the best case and appropriate when there isn't any work to do and useful
to give up the processor. This is an area where the API docs could
provide some guidance.
-Alan
More information about the loom-dev
mailing list