In the case of multi-threaded high concurrency, arrayList will throw concurrentModificationException
Resolve the situation
1.vector
2. Collections.synchronizedList(new ArrayList<>());
3. Use the CopyOnWriteArrayList
source code analysis under the JUC package
public boolean add(E e) {
final ReentrantLock lock = this.lock;
lock.lock();
try {
Object[] elements = getArray();
int len = elements.length;
Object[] newElements = Arrays.copyOf(elements, len + 1);
newElements[len] = e;
setArray(newElements);
return true;
} finally {
lock.unlock();
}
}