日期:2014-05-20  浏览次数:20561 次

Collections.synchronized
private   static   Map   sqlMap   =   Collections.synchronizedMap(new   HashMap());
private   static   Map   sqlMap   =   new   HashMap();
有什么区别~?  


------解决方案--------------------
synchronizedMap(Map <K,V> m)
返回由指定映射支持的同步(线程安全的)映射。
------解决方案--------------------
HashMap 是线程不安全的 ~~
private static Map sqlMap = Collections.synchronizedMap(new HashMap());
这样写就现程安全了,相当于HashTable