CopyOnWriteArrayList: Internal Working
Let's discuss the internal workings of CopyOnWriteArrayList.
We'll cover the following...
The internal workings of CopyOnWriteArrayList
is a very important topic for Java interviews. In this lesson, we will see how CopyOnWriteArrayList
provides thread-safety.
CopyOnWriteArrayList
is internally backed by an array, so let’s call it backarray for the purpose of understanding. Throughout this lesson, wherever we use the term backarray, it means the array in which all the elements added to theCopyOnWriteArrayList
is maintained.
There is a ReentrantLock defined in the CopyOnWriteArrayList
as shown below:
/** The lock protecting
...