Here it is the problem I am trying to solve but not sure how to do it: I have an array of objects (say size is 100) and each object has some id.
Class Employee{
int EmployeeId;
}
There are 10 threads which will read data from this array and insert it into database.
How to make sure data is inserted into DB based on the sequence of EmployeeId in increasing sequence. For example:
If array has objects with EmployeeID 6, 8 and 4, then these objects should be inserted in DB in sequence of EmployeeID 4,6,and 8 in DB. How to write multi-threaded code for this?
UPDATE: Please ignore DB part, if it is confusing, My main intention is to process concurrently but in sequence.