小虫正好说错了,HashMap 不是线程安全的,文档里加粗了这么一行字:
Note that this implementation is not synchronizedHashTable 是线程安全的,而且实现的 Servializable 接口,可以序列化。
但是 HashTable 的效率要比 HashMap 差一些,所以,如果不需要线程安全,也不需要序列化的情况下,不审用 HashMap 比较好一些。
Note that this implementation is not synchronizedHashTable 是线程安全的,而且实现的 Servializable 接口,可以序列化。
但是 HashTable 的效率要比 HashMap 差一些,所以,如果不需要线程安全,也不需要序列化的情况下,不审用 HashMap 比较好一些。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货