|
I was going through put ( ) and putAll ( ) methods
in Fast HashMap code in the struts . But did not get why we need to clone the
HashMap and add a entry to that cloned map then move that cloned map to original
HashMap . In multi- threaded enviornment anyway we synchronized the code that
accesses the HashMap in the put method .. ?
public Object put(Object key,
Object value) {
if
(fast) {
synchronized (this) { // IF U synchronize the code like this then easily only one thread can manipulate the HashMap HashMap temp = (HashMap) map.clone(); // What this do then ? Object result = temp.put(key, value); // map = temp; // return (result); } } else { synchronized (map) { return (map.put(key, value)); } } }
|
- Re: Fast Hashmap doubt . suhas
- Re: Fast Hashmap doubt . Calvin Yu
- RE: Fast Hashmap doubt . Byung Jin Chun

