Search Interview Questions
| More than 3000 questions in repository.|
There are more than 900 unanswered questions.
Click here and help us by providing the answer.
Have a video suggestion.
Click Correct / Improve and please let us know.
|Interview Questions and Answers|
|Ans. Synchronized List locks the whole list to provide synchronization and thread safety during the read or write operation, while, CopyOnWriteArrayList doesn’t lock the whole list during these operations. |
The CopyOnWriteArrayList class works according to its name i.e. copy-on-write which performs different actions for reading and write operations. For every write operation (add, set, remove, etc), it makes a new copy of the elements in the list. and for the read operations (get, iterator, listIterator, etc), it works on a different copy. So there is no additional overhead during a read operation and its read operation is faster than Collections.SynchronizedList(). Thus, COWAL is better for reading operation than Synchronized List.
|Help us improve. Please let us know the company, where you were asked this question :|
|Like Discuss Correct / Improve  Collections.synchronizedList()  CopyOnWriteArrayList|
|What is CopyOnWriteArrayList ?|
|What are the advantages and disadvantages of CopyOnWriteArrayList ?|