Is Java ArrayList / String / atomic variable reading thread safe?

前端 未结 6 1923
南方客
南方客 2021-02-14 00:27

I\'ve been mulling this over & reading but can find an absolute authoritative answer.

I have several deep data structures made up of objects containing ArrayLists, S

6条回答
  •  难免孤独
    2021-02-14 01:13

    I cannot see how reading from ArrayLists, Strings and primitive values using multiple threads should be any problem.

    As long as you are only reading, no synchronization should be necessary. For Strings and primitives it is certainly safe as they are immutable. For ArrayLists it should be safe, but I do not have it on authority.

提交回复
热议问题