Java Map convert to synchronized Map

Description

Java Map convert to synchronized Map


import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class Main {
  public static void main(String[] args) {
    Map<String, String> hashMap = new HashMap<String, String>();
    /*from  ww  w . ja va 2  s . co m*/
    System.out.println(hashMap.getClass());
    
    Map<String, String> map = Collections.synchronizedMap(hashMap);
    
    System.out.println(map.getClass());
  }
}



PreviousNext

Related