zoukankan      html  css  js  c++  java
  • Java的JDK下Hashtable与HashMap的区别

    时间角度: 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}.

  • 相关阅读:
    倒计时显示
    Global.asax实现屏蔽ip和图片防盗链
    同一账号不能同时登陆
    javascript中defer的作用
    javascript焦点图
    asp.net自定义分页
    GridVew linkbutton点击时获取点击行label的绑定值
    内存对齐
    深入.NET托管堆(Managed Heap)
    内存对齐1
  • 原文地址:https://www.cnblogs.com/rgqancy/p/5794788.html
Copyright © 2011-2022 走看看