How to synchronize ArrayList in java with example

We all know that  ArrayList class is non-synchronized and should not be used in multi-thread environment without explicit synchronization. In this article we will learn how to synchronize ArrayList in Java. We will be following two approaches here

  1. Using Collections.synchronizedList() method
  2. Using CopyOnWriteArrayList (thread-safe variant of ArrayList)

[Read more…]