How to avoid ConcurrentModificationException in multi-threaded code
You can use CopyOnWriteArrayList
or ConcurrentHashMap
etc. as you mentioned above or you can use Atomic*
classes which are working with CAS.
If you weren't aware of Atomic*
classes they definitely worth a look! You may check out this question.
So to answer your question you have to choose the right tools for the task. Since you do not share the context with us I can just guess. In some situations CAS will perform better in others the concurrent Collections will.
If something isn't clear you can always check out the official Oracle Trails: Lesson: Concurrency