J
James Yong
Hi,
I have google and couldn't find any tutorial/examples on using
ConcurrentHashMap.
Suppose I have the following three scenarios, what should I do to ensure
thread-safety?
if (!map.containsKey(key))
map.put(key, value);
for (int i=0; i<list.size(); i++) {
doSomething(list.get(i));
}
for (Iterator i=list.iterator(); i.hasNext(); ) {
doSomething(i.next());
}
Regards,
James Yong
I have google and couldn't find any tutorial/examples on using
ConcurrentHashMap.
Suppose I have the following three scenarios, what should I do to ensure
thread-safety?
if (!map.containsKey(key))
map.put(key, value);
for (int i=0; i<list.size(); i++) {
doSomething(list.get(i));
}
for (Iterator i=list.iterator(); i.hasNext(); ) {
doSomething(i.next());
}
Regards,
James Yong