从HashMap得到同步Map

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

public class MapFromHashMap {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    HashMap hashMap = new HashMap();
        Map map = Collections.synchronizedMap(hashMap);
        
        System.out.println("done");
}

}
Console:
done

你可能感兴趣的:(从HashMap得到同步Map)