InterviewSolution
| 1. |
What is CopyOnWriteArrayList? How it is different from ArrayList in Java? |
|
Answer» CopyOnWriteArrayList CREATES a clone of the actual list, for EVERY successive update operation will update internally to the actual list without generating the concurrent modification EXCEPTION, and prevent to throw the concurrent modification exception. HOWEVER, to use this cost more on memory consumption because for every update operation there is one clone copy gets created, we have to use wisely when there is frequent read operation, it is better to use when the same list is shared by a number of thread, whereas ArrayList doesn’t allow any thread safety. However whenever any modification takes place while traversing in the ARRAY lIst its throws the concurrent modification exception. |
|