java - Synchronize List vs synchronize object inside list -


lets have following list:

list<myobject> myobjectslist = new arraylist<>(); 

if this:

synchronized(myobjectslist ) {   //some code runs here... } 

does mean every object inside list thread safe or if other thread has reference of objects inside list can modify it?

... or if other thread has reference of objects inside list can modify it?

yes, can modify objects can acquire lock on myobject instances.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -