In Java, do I need to declare my collection synchronized if it's read-only?

后端 未结 5 1219
挽巷
挽巷 2021-02-12 12:30

I fill a collection one single time when my J2EE webapp starts. Then, several thread may access it at same time but only to read it.

I know using a synchronized collecti

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-12 13:07

    The collection itself does not, but keep in mind that if what it holds is not immutable also, those seperate classes need their own synchronization.

提交回复
热议问题