If I have an instance of an HashSet after I ran it through Collections.unmodifiableSet(), is it thread-safe?
I\'m asking this since Set documentation states that it\'s n
Every data structure is thread-safe if you don't mutate it.
Because you have to mutate a HashSet in order to initialize it, it is necessary to synchronize once between the thread which initialized the set and all reading threads. You have to do it only one time. For example when you pass the reference to the unmodifiable set to a new thread which never touched it before.