Code example for ConcurrentHashMap

Methods: containsKey, get, put

0
    private static final ConcurrentHashMap<String, SoftReference<UserHistoryDictionary>>
            sLangDictCache = CollectionUtils.newConcurrentHashMap();
 
    public static synchronized UserHistoryDictionary getInstance( 
            final Context context, final String locale, final SharedPreferences sp) {
        if (sLangDictCache.containsKey(locale)) {
            final SoftReference<UserHistoryDictionary> ref = sLangDictCache.get(locale);
            final UserHistoryDictionary dict = ref == null ? null : ref.get();
            if (dict != null) {
                if (PROFILE_SAVE_RESTORE) {
                    Log.w(TAG, "Use cached UserHistoryDictionary for " + locale);
                } 
                return dict;
            } 
        } 
        final UserHistoryDictionary dict =
                new UserHistoryDictionary(context, locale, sp);
        sLangDictCache.put(locale, new SoftReference<UserHistoryDictionary>(dict));
        return dict;
    } 
 
    private UserHistoryDictionary(final Context context, final String locale,
            final SharedPreferences sp) {