Updating a HashMap Concurrently

Hi

I am using a thread with a LinkedBlockingQueue to read updates from a service and push the data into a LinkedBlockingQueue.

For each of these update I want to retreive the corresponding record from a HashMap make some calculations on that record and write it back into the HashMap using ExecutorService execSvc = Executors.newCachedThreadPool();

.

Obviously if I get for example two updates for the same object these updates will be read in order into the LinkedBlockingQueue. However the thread which takes these recors from the LinkedBlockingQueue will attempt to put them into the hasMap using the ExecutorService execSvc = Executors.newCachedThreadPool();

thread pool. The order in which it writes the records is not guaranteed correct? If this is the case I may get invalid data in my hashmap.

How can I write the records in the order in which they were received to the hashmap?

Thanking you in advance...

[963 byte] By [java_swing_dudea] at [2007-11-27 9:14:52]
# 1
anone?
java_swing_dudea at 2007-7-12 22:03:26 > top of Java-index,Java Essentials,Java Programming...
# 2
Why don't you have just one thread taking objects from the queue and adding them to the map? If you use a different thread for each object you take out of the queue, then they can finish in a non-controlled order, defeating the FIFOness of the queue.
hunter9000a at 2007-7-12 22:03:26 > top of Java-index,Java Essentials,Java Programming...
# 3
I guess.... didn't understand.But, use Hashtable isn't an option?
pbulgarellia at 2007-7-12 22:03:26 > top of Java-index,Java Essentials,Java Programming...
# 4
> I guess.... didn't understand.> But, use Hashtable isn't an option?From what I understand, you have one queue, and you use several threads that each take a single object from the queue, and stick it in the map. Is that right?
hunter9000a at 2007-7-12 22:03:26 > top of Java-index,Java Essentials,Java Programming...