On Thu, 10 Mar 2022 10:44:45 GMT, Jaikiran Pai <j...@openjdk.org> wrote:
>> The acquire() method will return true the first time it's been called. And >> it is called only once. So we only need to check whether `acquired` is true >> at places where we are in doubt about whether the method has been called. >> The code that calls acquire() above could simply have ignored the result of >> `acquire()` and set the boolean to `true`. That said, it would not be wrong >> to check whether `acquired==true` here too - maybe I should do it for >> consistency... > >> The acquire() method will return true the first time it's been called. And >> it is called only once. So we only need to check whether acquired is true at >> places where we are in doubt about whether the method has been called. > > I see what you mean. Instead of checking `acquired` in the lambda - which requires `acquired` being final, I will add a line to assert that `assert acquired == true` after calling `acquire()`. ------------- PR: https://git.openjdk.java.net/jdk/pull/7196