The Java HashSet add method combines a contains and an add method as it returns true or false if the element is already present in the collection.
Is the add method atomic? I can use it in a multi-thread configuration and it will ensure that both operations will be run sequentially or the add method can be suspended between checking whether the element is present and effectively adding it to the collection?