[concurrency-interest] The code example in onSpinWait() Javadoc

Andrew Haley aph at redhat.com
Fri Nov 15 10:02:35 EST 2019

On 11/15/19 1:31 PM, Alex Otenko via Concurrency-interest wrote:
> I am not arguing. I want to see justification for wanting something that
> looks like a solution to an intractable problem.
> I see onSpinWait as an indicator to the JVM that it can do something
> useful, like possibly help FJP make some progress. I can't see how a time
> bound can be enforced there.

But that is not what "onSpinWait" means, that is what "yield" means.
The idea of "onSpinWait" is to reduce latency in spin loops, where
latency is measured in tens of nanoseconds. "onSpinWait" is not
supposed to free the processor to do something else.

I don't think there's anything much wrong with the example in the Javadoc,
and the Javadoc is not supposed to be a tutorial.

Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671

More information about the Concurrency-interest mailing list