I have a lot of confusion about Java's CopyOnWriteArrayist. I know, when we have a modification on it like update, insert of set, it will lock the whole list, copy out a total copy of the source list, do the modification and then release the lock. So, My question is:
When doing the modification, why cannot we just lock the array, do the modification and finally release the lock? Why we have to make a new copy of the array?
The write lock is only effective for a concurrent modification, but not for a modification and read. When we are doing a read, we read from the old array and get the old data, right?