博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java的JDK下Hashtable与HashMap的区别
阅读量:6161 次
发布时间:2019-06-21

本文共 1326 字,大约阅读时间需要 4 分钟。

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

基类与接口角度:

public class Hashtable<K,V>

extends Dictionary<K,V>
implements Map<K,V>, Cloneable, java.io.Serializable

public class HashMap<K,V>

extends AbstractMap<K,V>
implements Map<K,V>, Cloneable, Serializable

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

线程安全角度:

HashMap.java :

* <p><strong>Note that this implementation is not synchronized.</strong>

* If multiple threads access a hash map concurrently, and at least one of
* the threads modifies the map structurally, it <i>must</i> 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</a>. 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}.

 

 

转载地址:http://hjafa.baihongyu.com/

你可能感兴趣的文章
欧几里德算法(辗转相除法)
查看>>
面试题1-----SVM和LR的异同
查看>>
MFC控件的SubclassDlgItem
查看>>
如何避免历史回退到登录页面
查看>>
《图解HTTP》1~53Page Web网络基础 HTTP协议 HTTP报文内的HTTP信息
查看>>
unix环境高级编程-高级IO(2)
查看>>
树莓派是如何免疫 Meltdown 和 Spectre 漏洞的
查看>>
雅虎瓦片地图切片问题
查看>>
HTML 邮件链接,超链接发邮件
查看>>
HDU 5524:Subtrees
查看>>
手机端userAgent
查看>>
pip安装Mysql-python报错EnvironmentError: mysql_config not found
查看>>
http协议组成(请求状态码)
查看>>
怎样成为一个高手观后感
查看>>
[转]VC预处理指令与宏定义的妙用
查看>>
MySql操作
查看>>
python 解析 XML文件
查看>>
MySQL 文件导入出错
查看>>
java相关
查看>>
由一个异常开始思考springmvc参数解析
查看>>