I have a multithreading program which will hang after running a while. The stack after killing it shows that every single thread is hanging on the get method of a concurrentMap. I wonder what may cause this problem? I am wondering: 1: Is it possible to have deadlock when using concurrentMap? I am only doing simple get/put.... 2: Basically what may cause a multi-thread program to hang? Is it possible that the poor program just runs out of memory? Thank you!
Thank you all for the help. Just to make the problem specific:
Every worker thread is hang in the following state:
Classifier0" prio=10 tid=0x00007fda04420800 nid=0x16a2 runnable [0x00000000414ea000] java.lang.Thread.State: RUNNABLE at java.util.concurrent.ConcurrentHashMap.get()
And the program snippet:
for (String feature : features) {
Integer ti = this.descMap_.get(feature);
if (ti == null) {
ti = this.featureCount_.incrementAndGet();
this.descMap_.put(feature, ti);
this.featureMap_.put(ti, feature);
}
ans.add(new Entry<Integer, Value>(ti, tval));
}
featureCount_ is an AtomicInteger
Should be really simple code.....