Assume I have one threadpool and each thread is running following method:
void runMe(HashMap myHash){
...
myHash.remove(keyToBeRemoved);
...
}
My question is; should not myHash be the same in all threads at the beginning? Because my second thread does not have the key keyToBeRemoved. I was wondering why.
The
myHashreference may be the same for all threads, but when the first thread executesthen the hash map (which all references refer to) will no longer have that mapping.