Vote count:
0
I have class A which has a HashMap as a public field:
public static final HashMap<String, String> map = new HashMap<String, String>();
And in class B (which is multi-threaded, implements Runnable), I do some puts.
Now, in class C I'm tryin to read from the map. But the changes to the map are not reflected in class C.
I am not storing any references anywhere, but I access the map through the class name.
A.map.put("hi", "hello"); //in thread B
A.map.get("hi"); //in thread C
And I am sure that I call get() after I call put()..
I thought there could be a problem with concurrency and I changed the HashMap to a Hashtable but it is still the same..
Am I missing somethiing here?
asked 39 secs ago
Aucun commentaire:
Enregistrer un commentaire