- これは私がコードのHashMapに関するトピックを読んでいると、関連する質問/回答に
を見つけることができませんマルチスレッド Javaハッシュマップの重複するエントリを説明するには?
private Map<String, String> eventsForThisCategory;
...
Map<String, String> getEventsForThisCategory() {
if (eventsForThisCategory == null) {
Collection<INotificationEventsObj> notificationEvents = notificationEventsIndex.getCategoryNotificationEvents(getCategoryId());
eventsForThisCategory = new HashMap<String, String>();
for(INotificationEventsObj notificationEvent : notificationEvents) {
eventsForThisCategory.put(notificationEvent.getNotificationEventID(), notificationEvent.getNotificationEventName());
}
logger.debug("eventsForThisCategory is {}", eventsForThisCategory);
}
return eventsForThisCategory;
}
出力:
をapp_debug.9.log.gz:2014年4月7日13:47:06,661デバッグ[WirePushNotificationSyncHandler :: WirePushNot ification.Worker-1] - eventsForThisCategoryは、それが可能であるどのように{FX_WIRE_DATA =主要経済データ、ALL_FX_WIRE =すべて、ALL_FX_WIREは=すべて、FX_WIRE_HEADLINES =クリティカル見出し}
のですか?
[重複したキーをHashMapに入れた場合どうなるのですか?](http://stackoverflow.com/questions/1669885/what-happens-when-a-duplicate-key-is-put-into -a-hashmap) –
まあ、できません。少なくともHashMapではなく。コードにはどのような並行性がありますか? 2つの 'ALL_FX_WIRE'キーの間で異なる空白がありますか? –
Kayaman
@Kayamanマルチスレッドです。 2つのキーが異なる空白はありません。あなたが見ることができるように、それは地図を印刷し、それは文字列の自動トリムを行うとは思わない – Volodia