Thread Pool
Hi,
I have a HashMap storing objects of type Employee. This map is keyed by employee id. I have a data feed sending me employee updates at a rate of up to 200 to 300 employee updates persecond.
What I need to do is get the employee id from the data feed and check if it is in my Employee HashMap. If it is I need to update the entry if not I need to add a new emploee entry to the HashMap. Simple enough so far!!
Now, When these updates com in I have to perform calculations on the Employee objects in the Employee Hash map up date the employee object and store it back into the HashMap. I want to do this using threads to spped up the processing.
I have a recalculate method on my employee object which does the calculations required.
How best can I perform this functionality concurrently?
I am reading the data feed in a thread and storing these values in an updatedEmploee HashMap. I was thinking of using the Executors to perform the calculations in a thread. SHould I do this for each employee object or all the employee objects in the updatedEmployee HashMap?
ExecutorService execSvc = Executors.newCachedThreadPool();
for (int j = 0; j < numberOfUpdatedEmployees; j++){
Employees emp = (Employee) employeeMap.get(empID);
execSvc.execute(new Calculator(pos) );
}
execSvc.shutdown();
class Calculatorimplements Runnable{
Employee emp;
public Calculator(Employee emp){
this.emp = position;
publicvoid run(){
employee.recalculate();
employeeMap.put(empID, employee);
}
}
Am I thinking along the right lines? Can anyone suggest the best approach to take for this particular problem?
Thank you so much for your time on this.

