hg: jdk8/tl/jdk: 7145454: JVM wide monitor lock in Currency.getInstance(String)
David Holmes
david.holmes at oracle.com
Thu Mar 22 02:27:57 UTC 2012
Hi,
I'm sorry I missed the review of this change. The following is somewhat
inefficient:
instance = instances.putIfAbsent(currencyCode,
new Currency(currencyCode, defaultFractionDigits,
numericCode));
return (instance != null ? instance : instances.get(currencyCode));
If the putIfAbsent succeeds then the value to return is the newly
constructed Currency instance. So if we track that object then we don't
need to do the additional get():
Currency currencyVal =
new Currency(currencyCode, defaultFractionDigits, numericCode);
instance = instances.putIfAbsent(currencyCode, currencyVal);
return (instance != null ? instance : currencyVal);
Cheers,
David
On 22/03/2012 3:12 AM, naoto.sato at oracle.com wrote:
> Changeset: 4a5817f9e249
> Author: naoto
> Date: 2012-03-21 10:10 -0700
> URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/4a5817f9e249
>
> 7145454: JVM wide monitor lock in Currency.getInstance(String)
> Reviewed-by: okutsu
>
> ! src/share/classes/java/util/Currency.java
>
More information about the core-libs-dev
mailing list