diff -r d77ed23f4992 -r 2a63f5718d33 jdk/src/share/classes/java/util/Currency.java --- a/jdk/src/share/classes/java/util/Currency.java Tue Mar 20 15:06:13 2012 -0700 +++ b/jdk/src/share/classes/java/util/Currency.java Wed Mar 21 10:10:38 2012 -0700 @@ -34,6 +34,8 @@ import java.io.Serializable; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import java.util.logging.Level; import java.util.regex.Pattern; import java.util.regex.Matcher; @@ -99,7 +101,7 @@ // class data: instance map - private static HashMap instances = new HashMap(7); + private static ConcurrentMap instances = new ConcurrentHashMap<>(7); private static HashSet available; @@ -284,7 +286,6 @@ private static Currency getInstance(String currencyCode, int defaultFractionDigits, int numericCode) { - synchronized (instances) { // Try to look up the currency code in the instances table. // This does the null pointer check as a side effect. // Also, if there already is an entry, the currencyCode must be valid. @@ -322,10 +323,9 @@ } } - instance = new Currency(currencyCode, defaultFractionDigits, numericCode); - instances.put(currencyCode, instance); - return instance; - } + instance = instances.putIfAbsent(currencyCode, + new Currency(currencyCode, defaultFractionDigits, numericCode)); + return (instance != null ? instance : instances.get(currencyCode)); } /**