Synchronizing Objects within HashMap
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Nilesh_Phadke
Posted On:   Thursday, May 30, 2002 06:34 AM

I need to syncronize on Individual objects within a
hashMap. i.e can I lock individual objects stored in a
HashMap without having to lock the entire Hashmap.

Re: Synchronizing Objects within HashMap

Posted By:   Mike_Friedrich  
Posted On:   Saturday, June 1, 2002 02:44 AM

If you need syncronization all the time use Hashtable, or you can call

Map m = Collections.synchronizedMap(new HashMap(...));


Please read the JavaDoc of java.util.HashMap.

You can find something about syncronization there.


Regards, Mike.

Re: Synchronizing Objects within HashMap

Posted By:   Anonymous  
Posted On:   Thursday, May 30, 2002 06:37 AM

You can synchronize on a single object retreived from a HashMap, but that won't prevent the object from being replaced in the HashMap...
About | Sitemap | Contact