On Wed, 2 Apr 2025 14:31:46 GMT, Viktor Klang <vkl...@openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/StableValue.java line 455: >> >>> 453: * provided to the {@link #orElseSet(Supplier)} method. >>> 454: */ >>> 455: boolean trySet(T content); >> >> I assume the intent is that trySet can only return at most true once but the >> current wording suggests that two threads racing to set the same content >> would return true, or sequential calls to trySet to set the same content >> would return true. Does this need to be clarified? > > I second this So maybe "was set to the provided content" -> "was set by this call" >> src/java.base/share/classes/java/lang/StableValue.java line 494: >> >>> 492: * <p> >>> 493: * The provided {@code supplier} will only be invoked once even if >>> invoked from >>> 494: * several threads unless the {@code supplier} throws an exception. >> >> Is this the supplier instance or any supplier? Just wondering about the case >> where two threads are invoke it with different instances (for whatever >> reason), I can't tell from the javadoc. > > Seconded I personally think this is more of an implementation artifact for `StableValue::supplier` and doesn't merit its own API (as no other StableValue API utilizes the object monitor of a StableValue), but maybe we can adjust this in a later preview... ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2025846922 PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2025850569