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
Post a Comment