java 的HashMap高并发问题

2010/03/24 14:33
阅读数 2.4K

今天不知为什么服务器卡死了

把所有线程的堆栈打印出来是这样的
java.util.HashMap.get
..................

com.labox.common.net.ReceiveWorker.run
java.util.concurrent.ThreadPoolExecutor$Worker.runTask
java.util.concurrent.ThreadPoolExecutor$Worker.run
java.lang.Thread.run

所有线程都是卡死在这里了

后来也想不出为什么就用ConcurrentHashMap代替了

突然在ibm上发现一编文章是这写的

JR33299: 6.2.0.1: java.util.HashMap.get() causes high CPU use after migration

< ******** PASTE MAIN BODY CONTENT HERE ******** >
 Downloadable files
 
Abstract
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.
 
Download Description
JR33299 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 performance:

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:
None

PROBLEM 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解决的

展开阅读全文
加载中

作者的其它热门文章

打赏
0
2 收藏
分享
打赏
0 评论
2 收藏
0
分享
返回顶部
顶部