What does it mean when we say an ArrayList is not synchronized?
Does it mean that if we declare an ArrayList in object scope, multiple threads accessing the objects have the opportunity to modify the list?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It means that accessing an
ArrayListinstance from multiple threads may not be safe (read, “may result in unexpected behavior” or “may not work as advertised”).Further reading:
Even if it would have been thread safe, multiple threads would be able to modify the list.
The difference is that if it’s not thread safe and multiple threads access the list, all bets are off. Saying that the class is not thread safe, is the same as adding “If accessed from one thread at a time, this method works as follows…..” in front of every method description.