hashmap synchronization
1 posts in topic
Flat View  Flat View

Posted By:   vijay_M
Posted On:   Monday, June 22, 2009 02:42 AM

I have a hashmap which is modified (elements added or removed ) by one thread, and there is another thread (jsp) which accesses this map to display values using map.values.toarray . Is there a need for synchronization in the jsp, or will there be any performance impact because of the jsp repeatedly accessing the hashmap.

Re: hashmap synchronization

Posted By:   Edward_Harned  
Posted On:   Thursday, June 25, 2009 10:39 AM

Make the variable volatile. This way any thread that reads the variable will get the latest value. If only one thread writes the variable, then you don't need sync.

About | Sitemap | Contact