java jdk api hashmap_Java的JDK下Hashtable与HashMap的区别

时间角度:Hashtable* @since JDK1.0;HashMap* @since   1.2

基类与接口角度:

public class Hashtable

extends Dictionary

implements Map, Cloneable, java.io.Serializable

public class HashMap

extends AbstractMap

implements Map, Cloneable, Serializable

实现了一样的接口,继承自不同的基类(字典)Dictionary与(抽象映射)AbstractMap。

线程安全角度:

HashMap.java :

*

Note that this implementation is not synchronized.

* If multiple threads access a hash map concurrently, and at least one of

* the threads modifies the map structurally, it must be

* synchronized externally. (A structural modification is any operation

* that adds or deletes one or more mappings; merely changing the value

* associated with a key that an instance already contains is not a

* structural modification.) This is typically accomplished by

* synchronizing on some object that naturally encapsulates the map.

Hashtable.java :

* Java Collections Framework. Unlike the new collection

* implementations, {@code Hashtable} is synchronized. If a

* thread-safe implementation is not needed, it is recommended to use

* {@link HashMap} in place of {@code Hashtable}. If a thread-safe

* highly-concurrent implementation is desired, then it is recommended

* to use {@link java.util.concurrent.ConcurrentHashMap} in place of

* {@code Hashtable}.

8599d375cadda299046d9d9ea9e1ef61.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值