< prev index next >

src/java.base/share/classes/java/util/Hashtable.java

Print this page




  90  * after the iterator is created, in any way except through the iterator's own
  91  * {@code remove} method, the iterator will throw a {@link
  92  * ConcurrentModificationException}.  Thus, in the face of concurrent
  93  * modification, the iterator fails quickly and cleanly, rather than risking
  94  * arbitrary, non-deterministic behavior at an undetermined time in the future.
  95  * The Enumerations returned by Hashtable's {@link #keys keys} and
  96  * {@link #elements elements} methods are <em>not</em> fail-fast; if the
  97  * Hashtable is structurally modified at any time after the enumeration is
  98  * created then the results of enumerating are undefined.
  99  *
 100  * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed
 101  * as it is, generally speaking, impossible to make any hard guarantees in the
 102  * presence of unsynchronized concurrent modification.  Fail-fast iterators
 103  * throw {@code ConcurrentModificationException} on a best-effort basis.
 104  * Therefore, it would be wrong to write a program that depended on this
 105  * exception for its correctness: <i>the fail-fast behavior of iterators
 106  * should be used only to detect bugs.</i>
 107  *
 108  * <p>As of the Java 2 platform v1.2, this class was retrofitted to
 109  * implement the {@link Map} interface, making it a member of the
 110  * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
 111  *
 112  * Java Collections Framework</a>.  Unlike the new collection
 113  * implementations, {@code Hashtable} is synchronized.  If a
 114  * thread-safe implementation is not needed, it is recommended to use
 115  * {@link HashMap} in place of {@code Hashtable}.  If a thread-safe
 116  * highly-concurrent implementation is desired, then it is recommended
 117  * to use {@link java.util.concurrent.ConcurrentHashMap} in place of
 118  * {@code Hashtable}.
 119  *
 120  * @param <K> the type of keys maintained by this map
 121  * @param <V> the type of mapped values
 122  *
 123  * @author  Arthur van Hoff
 124  * @author  Josh Bloch
 125  * @author  Neal Gafter
 126  * @see     Object#equals(java.lang.Object)
 127  * @see     Object#hashCode()
 128  * @see     Hashtable#rehash()
 129  * @see     Collection
 130  * @see     Map




  90  * after the iterator is created, in any way except through the iterator's own
  91  * {@code remove} method, the iterator will throw a {@link
  92  * ConcurrentModificationException}.  Thus, in the face of concurrent
  93  * modification, the iterator fails quickly and cleanly, rather than risking
  94  * arbitrary, non-deterministic behavior at an undetermined time in the future.
  95  * The Enumerations returned by Hashtable's {@link #keys keys} and
  96  * {@link #elements elements} methods are <em>not</em> fail-fast; if the
  97  * Hashtable is structurally modified at any time after the enumeration is
  98  * created then the results of enumerating are undefined.
  99  *
 100  * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed
 101  * as it is, generally speaking, impossible to make any hard guarantees in the
 102  * presence of unsynchronized concurrent modification.  Fail-fast iterators
 103  * throw {@code ConcurrentModificationException} on a best-effort basis.
 104  * Therefore, it would be wrong to write a program that depended on this
 105  * exception for its correctness: <i>the fail-fast behavior of iterators
 106  * should be used only to detect bugs.</i>
 107  *
 108  * <p>As of the Java 2 platform v1.2, this class was retrofitted to
 109  * implement the {@link Map} interface, making it a member of the
 110  * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
 111  *
 112  * Java Collections Framework</a>.  Unlike the new collection
 113  * implementations, {@code Hashtable} is synchronized.  If a
 114  * thread-safe implementation is not needed, it is recommended to use
 115  * {@link HashMap} in place of {@code Hashtable}.  If a thread-safe
 116  * highly-concurrent implementation is desired, then it is recommended
 117  * to use {@link java.util.concurrent.ConcurrentHashMap} in place of
 118  * {@code Hashtable}.
 119  *
 120  * @param <K> the type of keys maintained by this map
 121  * @param <V> the type of mapped values
 122  *
 123  * @author  Arthur van Hoff
 124  * @author  Josh Bloch
 125  * @author  Neal Gafter
 126  * @see     Object#equals(java.lang.Object)
 127  * @see     Object#hashCode()
 128  * @see     Hashtable#rehash()
 129  * @see     Collection
 130  * @see     Map


< prev index next >