• Post Reply Bookmark Topic Watch Topic
  • New Topic

hashmap synchronization??  RSS feed

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

can anybody help me out in this, my question is..

Can we use "HashMap" for locking in synchronized block and invoke methods on the same HashMap instance.

Thanking in advance
 
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, without any problems.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using the current version of Java, you might want to check ConcurrentHashMap to see if it sovles what you are trying to do with HashMap. Here's a good article on the class, from Brian Goetz: http://www-128.ibm.com/developerworks/java/library/j-jtp08223/
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!