Time Angle: Hashtable * @since JDK1.0 ; HashMap * @since 1.2
base class and interface angle:
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
Implements the same interface, inheriting from different base classes (dictionaries) dictionary<k,v> with (abstract mappings) abstractmap<k,v>.
Thread-Safe angle:
Hashmap.java:
* <p><strong>note that this implementation are 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, an instance already contains are not a
* Structural modification.) This was 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's recommended to use
* {@link HashMap} in place of {@code Hashtable}. If a Thread-safe
* Highly-concurrent implementation is desired and then it's recommended
* To use {@link Java.util.concurrent.ConcurrentHashMap}
* {@code Hashtable}.
The difference between Hashtable and HashMap under the Java JDK