java question.

0 views
Skip to first unread message

Rajesh Inakota

unread,
Jul 12, 2011, 6:03:04 AM7/12/11
to freak...@googlegroups.com
When to use ConcurrentHashMap?
what is the difference between HashMap, HashTable and CorrentHashMap ?


--
Regards,
Rajesh.I

SURI

unread,
Jul 12, 2011, 4:17:31 PM7/12/11
to freak...@googlegroups.com, freak...@googlegroups.com
HashMap -- Offers non-synchronized methods.  -- Better response 
HashTable -- Offers synchronized methods with map level locks.  -- Slow response
ConcurrentHashMap -- Similar to HashTable with bucket level locking.. Performance of this is approach is some where in the middle of HashTable and HashMap.

-- SURI

Shyam Prakash Velupula

unread,
Jul 12, 2011, 11:04:20 PM7/12/11
to freak...@googlegroups.com
Suresh,

Does HashMap handle queries in async fashion?

- Shyam
--
You are limited only by your imagination

SURI

unread,
Jul 13, 2011, 2:48:59 AM7/13/11
to Freak-Your-Mind [FYM]
Shyam, I meant to say HashMap is not thread safe but HashTable is
thread safe.

But there is a way to make the HashMap thread safe :
Hashmap map = Collections.synchronizedMap(new HashMap(..))

There is another difference HashMap and HashTable is allowing null
values. HashTable doesn't allow null values as a key or a value.
Correct me if I am wrong here.

-- SURI

On Jul 13, 8:04 am, Shyam Prakash Velupula <velup...@gmail.com> wrote:
> Suresh,
>
> Does HashMap handle queries in async fashion?
>
> - Shyam
>

Shyam Prakash Velupula

unread,
Jul 13, 2011, 2:53:48 AM7/13/11
to freak...@googlegroups.com
Suresh,

Thanks for clarifying. I misunderstood the word "synchronized".
Actually, I have very basic understanding of Java.


- Shyam
Reply all
Reply to author
Forward
0 new messages