HashSet

1
2
3
public class HashSet<E>
extends AbstractSet<E>
implements Set<E>, Cloneable, java.io.Serializable

This class implements the Set interface, backed by a hash table (actually a HashMap instance).
Note that this implementation is not synchronized.
Set s = Collections.synchronizedSet(new HashSet(...));

阅读全文 »

Hashtable

1
2
3
public class Hashtable<K,V>
extends Dictionary<K,V>
implements Map<K,V>, Cloneable, java.io.Serializable
  • This class implements a hash table, which maps keys to values. Any non-null object can be used as a key or as a value.
  • fail-fast: if the Hashtable is structurally modified at any time after the iterator is created, in any way except through the iterator’s own remove method, the iterator will throw a {@link ConcurrentModificationException}.
    The Enumerations returned by Hashtables keys and elements methods are not fail-fast.

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}.
阅读全文 »

ReentrantLock

A reentrant mutual exclusion {@link Lock} with the same basic behavior and semantics as the implicit monitor lock accessed using {@code synchronized} methods and statements, but with extended capabilities.

1
public class ReentrantLock implements Lock, java.io.Serializable
阅读全文 »

ConcurrentHashMap

A hash table supporting full concurrency of retrievals and high expected concurrency for updates.

阅读全文 »

Map

SubClass should implements non-arguments constructor and constructor(Map)

This interface takes the place of the Dictionary class, which was a totally abstract class rather than an interface.

Note: great care must be exercised if mutable objects are used as map keys.

The behavior of a map is not specified if the value of an object is changed in a manner that affects equals comparisons while the object is a key in the map.
A special case of this prohibition is that it is not permissible for a map to contain itself as a key.
While it is permissible for a map to contain itself as a value, extreme caution is advised: the equals and hashCode methods are no longer well defined on such a map.

阅读全文 »

HashMap

1
2
public class HashMap<K,V> extends AbstractMap<K,V>
implements Map<K,V>, Cloneable, Serializable

Hash table based implementation of the Map interface.
This implementation provides all of the optional map operations, and permits null values and the null key.
(The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls.)
This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time.

阅读全文 »

StringBuilder

A mutable sequence of characters. This class provides an API compatible with {@code StringBuffer}, but with no guarantee of synchronization.
This class is designed for use as a drop-in replacement for {@code StringBuffer} in places where the string buffer was being used by a single thread (as is generally the case).
Where possible,it is recommended that this class be used in preference to {@code StringBuffer} as it will be faster under most implementations.
Unless otherwise noted, passing a {@code null} argument to a constructor or method in this class will cause a {@link NullPointerException} to be thrown.

1
2
3
public final class StringBuilder
extends AbstractStringBuilder
implements java.io.Serializable, CharSequence
阅读全文 »

JVM

参考Java虚拟机(JVM)
java原理实现: 从虚拟机到源码
深入理解java虚拟机

阅读全文 »
0%