Wednesday, January 30, 2008

When to use HashMap

Assume we do have a application scope HashMap. The key is the userId and the value would be some user information object.

This HashMap is a application level shared variable. Also this is a web application.

Users can access the hashMap delete the entries and add the entries.

But it is guranteed that no two users would address the same location(key) of the hashMap. reason is those two users has two keys and they are not the same.

At the same time if we make this object a HashTable then when one user modifies it other users has to wait (Syncronization handled implicitly). Which might lead to purformance issues.

Do u think it is good to use a HashMap in this scenario?

0 comments: