[concurrency-interest] A quiz or evaulation questions for java.util.concurrent package

Doron Rajwan doron at rajwan.org
Wed Jun 21 06:32:32 EDT 2006


ConcurrentHashMap<String,String> map = ...

Thread 1:
  map.put("A","A");
  map.put("B","B");

Thread 2:
  String b = map.get("B");
  String a = map.get("A");

Thread 3:
  Iterator<String> itr = map.keySet().iterator();
  ... check if A/B exists in itr.

Questions:
1. Can Thread2 see B but see A as null?
   Answer: no.
2. Can Thread3 see B but not A?
   Answer: yes.

Doron


______________________________________________________
Doron Rajwan, doron at rajwan.org, http://www.rajwan.org



More information about the Concurrency-interest mailing list