java的hashmap高并发问题
java 的 HashMap 高并发问题2010 年 1 月 9 日 114 views 评论 发表评论 今天不知为什么服务器卡死了把所有线程的堆栈打印出来是这样的java.util.HashMap.get……………….ReceiveWorker.runjava.util.concurrent.ThreadPoolcutor$Worker.runTaskjava.util.concurrent.ThreadPoolcutor$Worker.runjava.lang.Thread.run所有线程都是卡死在这里了后来也想不出为什么就用 ConcurrentHashMap 代替了突然在 ibm 上发现一编文章是这写的JR33299: 6.2.0.1: java.util.HashMap.get() causes high CPU use after migrationDownloadable filesAbstractAfter migration of a WebSphere InterChange Server repository and deployment of the migrated artifacts to WebSphere Process Server, the migrated content causes high CPU use.Download DescriptionJR33299 resolves the following problem:ERROR DESCRIPTION:After migration of a WebSphere InterChange Server repository and deployment of the migrated artifacts to WebSphere Process Server, the migrated content causes high CPU use when calling the BusObj API. The thread dump shows that many threads are waiting, which causes a degradation in perance:at java.util.HashMap.get(HashMap.java:346)at CxCommon.BusinessObject.(BusinessObject.java:277)at Collaboration.BusObj.(BusObj.java:94)Using ConcurrentHashMap instead of HashMap can bypass this Java problem.LOCAL FIX:You can possibly avoid this problem by reducing the concurrency of the system.USERS AFFECTED:WebSphere Process Server v6.2.0.1 users who migrate a WebSphere InterChange Server repository.PROBLEM DESCRIPTION:After migration of a WebSphere InterChange Server repository and deployment of the migrated artifacts to WebSphere Process Server, high CPU is seen in java.util.HashMap.get(), which is called by an early version of the BusObj API.RECOMMENDATION:NonePROBLEM SUMMARY:java.util.HashMap is not thread-safe and can cause high CPU use when HashMap is used in a concurrent setting with insufficient synchronization.PROBLEM CONCLUSION:Applying this interim fix resolves the problem. The fix for this APAR is targeted for inclusion in a future v6.2.0 fix pack.好明显,ibm 的 websphere 也遇到这个问题,后来也是把 hashMap 换成ConcurrentHashMap 解决的