multithreading - In java, what happens when deleting an object while it is being used? -
here scenario:
i have java hashtable takes string key , object value.
one thread gets object using key , calls method on object.
while method doing operation step b), thread calls remove on particular key references object.
what happens ?
should put lock on operation ?
nothing happens, assuming you're talking (thread-safe) java.util.hashtable
. removing object hashtable
has no impact on other references object.
objects eligible garbage collection once nothing references them.
Comments
Post a Comment