jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java
changeset 6835 859aa05172b6
parent 6501 684810d882b3
child 10710 b18db2d63e3b
equal deleted inserted replaced
6834:303c8cca4a31 6835:859aa05172b6
    82     /**
    82     /**
    83      * Available locales within this JRE.  Currently this is declared as
    83      * Available locales within this JRE.  Currently this is declared as
    84      * static.  This could be non-static later, so that they could have
    84      * static.  This could be non-static later, so that they could have
    85      * different sets for each locale sensitive services.
    85      * different sets for each locale sensitive services.
    86      */
    86      */
    87     private static List<Locale> availableJRELocales = null;
    87     private static volatile List<Locale> availableJRELocales = null;
    88 
    88 
    89     /**
    89     /**
    90      * Provider locales for this locale sensitive service.
    90      * Provider locales for this locale sensitive service.
    91      */
    91      */
    92     private Set<Locale> providerLocales = null;
    92     private Set<Locale> providerLocales = null;
   250      * service lookup) supported by the JRE.
   250      * service lookup) supported by the JRE.
   251      * Note that this method does not return a defensive copy.
   251      * Note that this method does not return a defensive copy.
   252      *
   252      *
   253      * @return list of the available JRE locales
   253      * @return list of the available JRE locales
   254      */
   254      */
   255     private synchronized List<Locale> getJRELocales() {
   255     private List<Locale> getJRELocales() {
   256         if (availableJRELocales == null) {
   256         if (availableJRELocales == null) {
   257             Locale[] allLocales = LocaleData.getAvailableLocales();
   257             synchronized (LocaleServiceProviderPool.class) {
   258             availableJRELocales = new ArrayList<Locale>(allLocales.length);
   258                 if (availableJRELocales == null) {
   259             for (Locale locale : allLocales) {
   259                     Locale[] allLocales = LocaleData.getAvailableLocales();
   260                 availableJRELocales.add(getLookupLocale(locale));
   260                     availableJRELocales = new ArrayList<Locale>(allLocales.length);
       
   261                     for (Locale locale : allLocales) {
       
   262                         availableJRELocales.add(getLookupLocale(locale));
       
   263                     }
       
   264                 }
   261             }
   265             }
   262         }
   266         }
   263         return availableJRELocales;
   267         return availableJRELocales;
   264     }
   268     }
   265 
   269