【Java】hashMap和hashTable的区别

HashMap Hashtable都实现了Map接口

HashMap是非synchronized的, Hashtable是synchronized的

HashMap使用Iterator, Hashtable使用Enumeration

Hashtable直接使用对象的hashcode,hashmap重新计算hash值,而且用与代替求模。


线程安全的map在JDK 1.5及其更高版本环境中,有哪几种方法可以实现?

Map map = new ConcurrentHashMap();

Map map = Collections.synchronizedMap(new HashMap());

猜你喜欢

转载自blog.csdn.net/michellechouu/article/details/48751745