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.
CopyOnWriteArrayListI cant use as it creates copy on each write so load would be too much on memoryArrayList: I can use newArrayListfor each task and insert objects read by task in its localAraylistand return it asFuture. When all tasks are done, I will merge allArrayListto one. Here no ofArrayListequal to number of Task I have created.
Is there any better concurrent List data structure I can use for storing objects ?