On Tue, 9 Mar 2021 06:42:51 GMT, Yasumasa Suenaga <[email protected]> wrote:
>> Ok, that's easy enough. What about the loop before it. Do you prefer 100ms
>> sleeps or onSpinWait() for it also.
>
> I prefer `onSpinWait()` if anything because it expects short suspend, and we
> can expect CPU friendly code.
As an option, we can remove `steadyStateReached` and rewrite the code as
following:
steadyStateThread.setName("SteadyStateThread");
steadyStateThread.start();
while (steadyStateThread.getState() != Thread.State.BLOCKED) {
Thread.onSpinWait();
}
-------------
PR: https://git.openjdk.java.net/jdk/pull/2700