On Thu, 3 Oct 2024 17:15:34 GMT, Archie Cobbs <aco...@openjdk.org> wrote:
>> fabioromano1 has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Code simplification > > src/java.base/share/classes/java/math/BigDecimal.java line 5238: > >> 5236: BigInteger pow = FIVE_TO_2_TO[FIVE_TO_2_TO_LEN - 1]; >> 5237: for (int i = FIVE_TO_2_TO_LEN; i <= n; i++) >> 5238: FIVE_TO_2_TO[i] = pow = pow.multiply(pow); > > Drive-by comment... apologies if I'm missing some subtle context. Doesn't > this raciness create a bug? The field `FIVE_TO_2_TO_LEN` is read multiple > times, and other threads could be incrementing it while this code executes, > which would lead to an incorrect value for `pow`, etc. @archiecobbs AFAIK, the documentation of `BigDecimal` does not specify that the class is thread-safe, but I could be wrong... ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1788012854