java - Synchronized objects while iterating ArrayList -


let's have following scenario:

final int index = 10; phone phone = phonelist.get(index); synchronized(phone) {    //some code runs here } 

so while the phone object (which got throught phonelist.get() method) locked can thread execute method:

phonelist.remove(index); 

and null phone object @ given index?

yes. why not?

but still, phone pointing same object. i.e. object gets removed list jvm still has reference it.


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 -