InterviewSolution
| 1. |
How And Why To Synchronize Arraylist In Java? |
|
Answer» In order to have better performance most of the COLLECTIONS are not synchronized. Which means sharing an instance of arrayList among many threads where those threads are MODIFYING (by adding or removing the values) the COLLECTION may RESULT in unpredictable behaviour. To synchronize a List Collections.synchronizedList() method can be used. In order to have better performance most of the Collections are not synchronized. Which means sharing an instance of arrayList among many threads where those threads are modifying (by adding or removing the values) the collection may result in unpredictable behaviour. To synchronize a List Collections.synchronizedList() method can be used. |
|