<div dir="ltr"><div>Just MHO... </div><div><br></div><div>This is kind of like asking "What's the best way to waste electricity?"</div><div><br></div><div>It's a nebulous question until you specify what "best" means in this odd scenario.... </div><div><br></div><div>-Archie</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, Jun 15, 2025 at 11:09 AM Markus KARG <<a href="mailto:markus@headcrashing.eu">markus@headcrashing.eu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Recently I was asked by a programmer, what to do if there simply is no <br>
other way than actually busy-wait.<br>
<br>
I see several options:<br>
<br>
* Do nothing: Costs valuable CPU time and increases carbon footprint.<br>
<br>
* Do a power-nap: Thread.sleep(1)<br>
<br>
* Be fair: Thread.yield() gives other threads a chance to execute in <br>
this time slot.<br>
<br>
* Be eco-friendly: Thread.onSpinWait() could reduce carbon footprint.<br>
<br>
* A combination of that, like "Thread.yield(); Thread.onSpinWait();"<br>
<br>
As all of that has its pros and cons, and as all of that works <br>
differently on each hardware platform, I do wonder if there is some <br>
common sense / best practice for busy wait (other than "Replace it using <br>
async") in the core-libs team?<br>
<br>
Thanks!<br>
<br>
-Markus<br>
<br>
<br>
<br>
</blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div>