Question 1
ConcurrentHashMap is a hash table implementation that supports full concurrency of retrievals and high expected concurrency for updates. All operations on this collection are thread-safe. Consider the code given below that uses a ConcurrentHashMap, and answer the question that follows.
class Example extends Thread{ Map siMap; //Constructor is defined here public void run(){ siMap.put("D",4); }}public class FClass{ public static void main (String[] args) { Map<String, Integer> siMap = new ConcurrentHashMap<String, Integer>(); String[] str = {"A", "B", "C"}; Integer[] arr = {1, 2, 3}; for(int i = 0; i < str.length; i++){ siMap.put(str[i],arr[i]); }
Example t = new Example(siMap); t.start(); Set s = siMap.entrySet(); Iterator itr = s.iterator(); while(itr.hasNext()){ Map.Entry m = (Map.Entry)itr.next(); System.out.println(m.getKey() + " => " + m.getValue()); } }}Which of the following is NOT true about the given code?