There are many different collections in Java designed for concurrency and thread safety, and I am at a loss as to which one to choose for my situation.
Several threads can call .add() and .remove() , and I will copy this list often with something like List<T> newList = new ArrayList<T>(concurrentList) . I will never iterate over a parallel list.
I thought of something like CopyOnWriteArrayList , but I read that it can be very inefficient because it copies itself every time it changes. I hope to find a good compromise between safety and efficiency.
What is the best list (or set) for this situation?
source share