Re: The code example in onSpinWait() Javadoc

Andrew Haley via Concurrency-interest <[email protected]>
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <[email protected]>
On 11/17/19 11:46 PM, Doug Lea via Concurrency-interest wrote:

> Usage may interact with GC, reference handling, and safepoints: in
> some contexts "a short while" isn't usually short, but we don't have
> a way of portably discussing such issues in javadocs. It's also one
> of the reasons we don't include a spinlock utility -- we cannot
> easily guess how best to write one that works well across enough
> usage contexts. (But we do make it easy to write them via tryLock.)

Sure, these ideas are hard to express if we restrict ourselves to
the mythical "write once, run anywhere" Java, but by the time we're
talking about writing our own spinlocks we're a long way from that.

"Everybody" ;-) knows that you should only spin for about (half?) the
same time as a simple system call, and that this is about 1000
iterations of a trivial loop. Intuitively this makes sense: you don't
want to make an (expensive) system call rather than just waiting for a
little while.

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

_______________________________________________
Concurrency-interest mailing list
[email protected]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.