Suppose I want to read the huge file where each line represents domain objects, and I need to store this information in cache. This file is read using multiple threads. Each thread is reading certain range of lines and they will put mapped object in List. At the end when all the submitted tasks are finish, you should have full list with all objects from file.
CopyOnWriteArrayList
I cant use as it creates copy on each write so load would be too much on memoryArrayList
: I can use newArrayList
for each task and insert objects read by task in its localAraylist
and return it asFuture
. When all tasks are done, I will merge allArrayList
to one. Here no ofArrayList
equal to number of Task I have created.
Is there any better concurrent List
data structure I can use for storing objects ?