I'm implementing a logging for multiple threads, each will write into a List
. After all threads have finished I will then dump the contents of the List
into a file. Which concurrent List
implementation should I use?
I'm considering the ConcurrentLinkedQueue.
- The writing will be concurrent, but the reading will be done by one thread, after all other threads have finished writing.
I could use a List
for each thread but then I would have the overhead of managing multiple List
s and I'm not sure it is worth it. Another option would be a synchronized List.
Bonus question: How do I make the last thread dump the list into the file? See Multiple threads arrive, the last should do the processing.