这类线程安全吗?或者我是否必须在地图上添加同步?
public class MapTest {
private static final TreeMap<String,String> map = new TreeMap<>();
public static final synchronized String get(String key){
return map.get(key);
}
public static final synchronized void put(String key,String value){
map.put(key,value);
}
}