> The takeaway from this exercise is that loops with sleeps can't always be > replaced by loops that busy-wait. > Functionally the logic is the same, but you can't just ignore the concurrency > aspects.
Thanks for explanation! > Which indicates yielding is having a similar effect to sleeping - though I > would expect it to be less pronounced. May I ask one last question about this: in general case when we don't care about particular wait time (like in j.n.Bits.reserveMemory()) should I prefer Thread.yield() over both Thread.sleep() and Thread.onSpinWait() providing that Thread.sleep() is expensive and Thread.onSpinWait() might cause undesirable side effects? Regards, Sergey Tsypanov