File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How ConcurrentHashMap is synchronized? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How ConcurrentHashMap is synchronized?" Watch "How ConcurrentHashMap is synchronized?" New topic
Author

How ConcurrentHashMap is synchronized?

jami siva
Ranch Hand

Joined: Oct 16, 2009
Posts: 63
I saw ConcurrentHashMap API class, but in that I didn't find any method or block with synchronized keyword. Then How ConcurrentHashMap is synchronized.


Thanks,
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

jami siva wrote:I saw ConcurrentHashMap API class, but in that I didn't find any method or block with synchronized keyword. Then How ConcurrentHashMap is synchronized.


Like many of the java.util.concurrent classes, added with Java 5, it is made thread safe optimistically -- with the atomic libraries. This is why the ReentrantLock class, which implements the synchronized functionality, is actually faster (under many conditions).

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

jami siva wrote:I saw ConcurrentHashMap API class, but in that I didn't find any method or block with synchronized keyword. Then How ConcurrentHashMap is synchronized.

Probably with ReentrantLock's, but the fact is I don't honestly know - and you don't need to either.

That's the whole point of Object-Orientation: You don't need to know how something works; you just need to know what it does.
And for more info on that subject, you might want to read the WhatNotHow (←click) page.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How ConcurrentHashMap is synchronized?