ArrayList extends AbstractList Class.
ArrayList implements List, Random Access, Cloneable, Serializable.
ArrayList is resizable-array implementation of the List interface.
Its permit all the elements including null also.
ArrayList is roughly equivalent to Vector, except that ArrayList is unsynchronized.
The Size, is Empty and all other operations run in constant time.
The add operation runs in amortized constant time, that is adding n elements require O(n) time.
How to Make arraylist as threadsafe?
If multiple threads access as ArrayList instance oncurrently, and at least one of the threads modifies the list structurally, it must be synchronized externally.
Structural Modification: Any operation thats adds or deletes one or more elements, or explicitly resizes the backing array, just setting the value of an element is not a structural modification.
This can be achieved by 2 way:
By synchronizing on some object that naturally encapsulates the list.
If no such objects exists, the list should be "wrapped" using the Collections.synchronizedList method.
List list= Collections.sysnchronizedList(new ArrayList(...));
The iterators will fails and throw ConcurrentModificationException if there will any structural modification on the list.