is Java HashSet thread-safe for read only?

前端 未结 7 1407
清酒与你
清酒与你 2021-02-01 16:51

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

相关标签:
7条回答
  • 2021-02-01 17:21

    If the shared memory will never be changed, you can always read without synchronizing. Making the set unmodifiable will just enforce the fact that no writes can be made.

    0 讨论(0)
提交回复
热议问题