Does the unmodifiable wrapper for java collections make them thread safe?

前端 未结 9 726
小鲜肉
小鲜肉 2020-12-30 02:10

I need to make an ArrayList of ArrayLists thread safe. I also cannot have the client making changes to the collection. Will the unmodifiable wrapper make it thread safe or d

9条回答
  •  天涯浪人
    2020-12-30 02:23

    The unmodifiable wrapper only prevents changes to the structure of the list that it applies to. If this list contains other lists and you have threads trying to modify these nested lists, then you are not protected against concurrent modification risks.

提交回复
热议问题