小虫正好说错了,HashMap 不是线程安全的,文档里加粗了这么一行字:
Note that this implementation is not synchronizedHashTable 是线程安全的,而且实现的 Servializable 接口,可以序列化。
但是 HashTable 的效率要比 HashMap 差一些,所以,如果不需要线程安全,也不需要序列化的情况下,不审用 HashMap 比较好一些。