Why can java.util.HashMap.getEntry block my program?

my program was blocked, I used the jstack command for analysis, the next thread took the lock "0x0000000603f02ae0", and other threads could not get the lock.
I have been waiting for at least one hour, but the thread has not been unlocked, my question is why thread_state is RUNNING and stops at java.util.HashMap.getEntry (HashMap.javahaps47)? is it an oracle (sun) JDK bug?

my jdk version:
java version "1.6.0_21"
Java (TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot (TM) 64-bit server VM (build 17.0-b16, mixed mode)


Thread Information: "PandoraScheduleTrigger-thread-5" prio = 10 tid = 0x00000000443b0800 nid = 0x5804 runnable [0x0000000043722000] java.lang.Thread.State: RUNNABLE in java.util.HashMap.getEntry (HashMap.// .util.HashMap.containsKey (HashMap.javahaps35) at com.youlongqingfeng.pandora.context.ArmiesContext._getArmy (ArmiesContext.java:239) at com.youlongqingfeng.pandora.context.ArmiesContext.getA16ies Armyies ) at com.youlongqingfeng.pandora.model.City.getTotalApplianceMap (City.java:4519) at com.youlongqingfeng.pandora.model.City.calculateMemoryResource (City.java:4636) at com.youlongqingfeng.pandora.model.ity. buildTaskFinish (City.java:1089) at com.youlongqingfeng.pandora.map.unit.ZhouMapResourceUnit.buildTaskFinish (ZhouMapResourceUnit.java:1618) -blocked by <0x0000000603f02ae0> (com.youlongqingfeng.pandora.map.unit.ZhouMapResourceUnit) at com.youlongqingfeng.pandora.trigger.BuildTrigger.innerRun (BuildTrigger.java:39) on com.youlongqingut.englerthers.grlthread.ames (CancelTrigger.java:34)

Blocked flow dump:

"PandoraScheduleTrigger-thread-3" prio = 10 tid = 0x0000000044c7c000 nid = 0x5802 waiting for the input of the monitor [0x0000000043520000] java.lang.Thread.State: BLOCKED (on the object monitor) on com.youlongqingfeng.pandora.map.unit.GurnMurnetzurnetzurnmurnetzurnetzurnmurnetzurnetzurnmurn (ZhouMapResourceUnit.java:2279) - waiting for a lock <0x0000000603f02ae0> (com.youlongqingfeng.pandora.map.unit.ZhouMapResourceUnit)   at com.youlongqingfeng.pandora.trigger.ArmyGroupArrivedTrigger.innerRun(ArmyGroupArrivedTrigger.java:53)    com.youlongqingfeng.gameserver.utils.threadpool.CancelTrigger.run(CancelTrigger.java:34)    java.util.concurrent.Executors $RunnableAdapter.call(Executors.java:441)    java.util.concurrent.FutureTask $Sync.innerRun(FutureTask.java:303)    java.util.concurrent.FutureTask.run(FutureTask.java:138)    java.util.concurrent.ScheduledThreadPoolExecutor $ScheduledFutureTask.access $301 (ScheduledThreadPoolExecutor.java:98)    java.util.concurrent.ScheduledThreadPoolExecutor $ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:207)    java.util.concurrent.ThreadPoolExecutor $Worker.runTask(ThreadPoolExecutor.java:886)    java.util.concurrent.ThreadPoolExecutor $Worker.run(ThreadPoolExecutor.java:908)    java.lang.Thread.run(Thread.java:619)

.

+3
4

, ConcurrentHashMap HashMap. HashMap , - . ConcurrentHashMap. . , , .

+5

, :

  • HashMap, . , ? , , , .

  • , . , , 2 , 2 , , , , ? ( 1 a, b + 2 b β†’ .)

+3

Are you sure the thread stopped at getEntry? The state is doable , so I assume it is running? In this step you catch jstack, that’s it. I assume that there is some infinite loop under the ZhouMapResourceUnit.buildTaskFinish object, and the lock will never be released.

+2
source

Use a Hashtable if there are multiple threads and a HashMap if there is only one thread.

0
source

Source: https://habr.com/ru/post/1758494/


All Articles