java 的HashMap高并发问题

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

把所有线程的堆栈打印出来是这样的
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解决的

转载于:https://my.oschina.net/javagg/blog/3358

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值