Assuming we had this class
final class Foo {
private final Set bar = new HashSet<>();
public Foo() {
bar.add(\"one\");
It is thread safe provided that
1) The constructor does not leak a reference before its fully constructed.
2) No one has any way to access the collection.
3) No subclass can be created which can edit the collection.
As a general rule though, if you want to implement this use an immutable collection from guava, that makes the behaviour explicit to the programmer, and it is then safe to return the whole map. I think that in pure java you can return an unmodifiable view of a collection.