Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added quote from api

...

... even though all operations are thread-safe, retrieval operations do not entail locking, and there is not any support for locking the entire table in a way that prevents all access. This class is fully interoperable with Hashtable in programs that rely on its thread safety but not on its synchronization details.

In general, use client-side locking only when the documentation of the class recommends it. For example, the documentation of the wrapper method synchronizedList() of class java.util.Collections states:

In order to guarantee serial access, it is critical that all access to the backing list is accomplished through the returned list. It is imperative that the user manually synchronize on the returned list when iterating over it. Failure to follow this advice may result in non-deterministic behavior.

Noncompliant Code Example

...