multithreading - In java, what happens when deleting an object while it is being used? -


here scenario:

  1. i have java hashtable takes string key , object value.

  2. one thread gets object using key , calls method on object.

  3. 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

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -