+ 1

What is the use of synchronization in java e.g. java arraylist is non synchronized... what does it really means

need suggestions

2nd Apr 2017, 2:37 PM
Akash A
Akash A - avatar
2 ответов
+ 6
@Felipe Is it like I have an Array List, if I run Thread A and Thread B, in which Thread A remove one of the element in the Array List, then the index of the other elements after it will change, then when I access the Array List in Thread B will cause problem?
3rd Apr 2017, 10:39 AM
Heng Jun Xi
Heng Jun Xi - avatar
+ 1
It is a multithread concept. Synchronized methods enable a simple strategy for preventing thread interference and memory consistency errors. Accessing an ArrayList instance from multiple threads may not be thread safe if you don't manage that.
3rd Apr 2017, 10:25 AM
Felipe Cruz
Felipe Cruz - avatar