I have a data generation code which generates records, each record is of multiple user selected fields. To speed up the processes I'm splitting the task to create records in batches, to create records in parallel
For example : If i want to generate 10k records I'm splitting it in 5 task
like say
Task 1 : create record from 1-2k
Task 2 : create record from 2001-3k
...
Task 5 : create record from 8001-10k
And i want each thread to store records in container. As the container is filled up to a limit say initial 1k records, then one task waiting to export data will start removing the records sequentially.
My option was using Hash Map, as sequence is important but its not at all memory efficient as even if Map is empty more than 50% the size taken by Map on heap remains same until the Map is GC.
So considering my above scenario what is the best fit for container?