Let's say i have the following scenario:
final int index = 10;
Phone phone = phoneList.get(index);
synchronized(phone)
{
//some code runs here
}
So while the the phone object (which is got throught phoneList.get() method) is locked can another thread execute the method:
phoneList.remove(index);
and null the phone object at the given index?
Yes. why not?
But still, phone
will be pointing to the same object. i.e. the object gets removed from list but the jvm still has reference to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With