title: HashSet and multithreading
body: <p>I work on Java 7.</p>
  
  <p>I want to know if the method <code>contains</code> is thread-safe on HashSet object.</p>
  
  <p>The HashSet is initialized by one thread. Then we wrap the HashSet with unmodifiable collection (<code>Collections.unmodifiableSet</code>). After initialization, multiple threads call only the method <code>contains</code>.</p>
  
  <p>When I read the Javadoc, it's unclear for me.</p>
  
  <p>On <a href="https://docs.oracle.com/javase/7/docs/api/java/util/HashSet.html" rel="noreferrer">HashSet Javadoc</a> we can read </p>
  
  <blockquote>
    <p>This class implements the Set interface, backed by a hash table (actually a HashMap instance). </p>
  </blockquote>
  
  <p>...</p>
  
  <blockquote>
    <p><strong>Note that this implementation is not synchronized.</strong></p>
  </blockquote>
  
  <p>And on the <a href="https://docs.oracle.com/javase/7/docs/api/index.html?java/util/HashSet.html" rel="noreferrer">HashMap Javadoc</a>, we can read:</p>
  
  <blockquote>
    <p>Note that this implementation is not synchronized. If multiple threads access a hash map concurrently, and at least one of the threads modifies the map structurally, it must be synchronized externally. (<strong>A structural modification is any operation that adds or deletes one or more mappings</strong>; merely changing the value associated with a key that an instance already contains is not a structural modification.) </p>
  </blockquote>
  
  <p>For me, this means the method <code>contains</code> is not a structural modification.</p>
  
  <p>So multiple call to the method <code>contains</code> is it thread-safe?</p>
  
  <p>If it's true: Is it guaranteed on all implementation of JVM (like IBM JVM)?</p>