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...

