I am using multithreading
to process huge # of records coming through file. Each line is one record and I pass each line to separate thread for processing.The problem is that I have to collect these processed record and some more data generated while processing the record and then apply some business logic on final collection of data. I pass a common ConcurrentHashMap
to all the threads to populate the processed data and when I debuged it through visualVM I found(screenshot as below) that these threads are spending lot of time in waiting than running. I suppose that is because of the lock one thread acquire while writing to ConcurrentHashMap
.
Is there a way I could implement complete asynchronous behavior to achieve my goal?
visualVM snapshot