• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How ConcurrentHashMap is synchronized?

 
jami siva
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21184
80
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Winston Gutkowski
Bartender
Pie
Posts: 10422
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic