static HashMap Issue

Hi , Actually i am fetching data from client after 2 or 3 seconds. i am trying to store all the information in a HashMap. I want this hashmap to be static so i have declared it static so that it can save All the values i recieve. Problem is that it saves only 7 Values and then i think Revised itself. Structure goes like this

1) there is a class in which HashMap is defined and Intialized.

2) i am accessing it in some Other Class like this MyHashMapClass.myHashMap

3) I am setting values like this MyHashMapClass.myHashMap.put("id",strId);

4) Then passing it(static HashMap) to some thread for some Operation after 20 secods. like for 20 seconds it saves 7 values . 7 x 3 case. but next time its size should be 14 right.? but it shows it be 7 always. Your Help is appriciated.

Regards,

Adnan

[838 byte] By [Adeea] at [2007-11-27 8:32:27]
# 1
Please show some more code that will definitely help.
sachin.agrawala at 2007-7-12 20:28:18 > top of Java-index,Core,Core APIs...
# 2
well one possible answer is that u are using Hashmap and more then one thread is modifying it. So u should use Hashtable or Collections.synchronizedMap(Map<K,V> m).
sachin.agrawala at 2007-7-12 20:28:18 > top of Java-index,Core,Core APIs...
# 3
Thanks for Reply. No Only one Thread is Modifying it.
Adeea at 2007-7-12 20:28:18 > top of Java-index,Core,Core APIs...
# 4
One possible thing is that you have only 7 distinct keys that's why only seven values. Please show some code then i would be more helpful to you.
sachin.agrawala at 2007-7-12 20:28:18 > top of Java-index,Core,Core APIs...
# 5
yes you got it right. Alrightt The keys are not different does it matter. ? Means it replaces/updates previous values.? and it does not add values with the same Key.? Code is same as structure i mentioned earlier. Thanks for reply.
Adeea at 2007-7-12 20:28:18 > top of Java-index,Core,Core APIs...
# 6
Yes, using the same key again means overwriting the value, not adding a new one. The HashMap.put() doc says:"If the map previously contained a mapping for this key, the old value is replaced."(From http://java.sun.com/j2se/1.5.0/docs/api/index.html)
OleVVa at 2007-7-12 20:28:18 > top of Java-index,Core,Core APIs...