Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does synchronized mean in context of Vector / ArrayList?

I've just read up some information on Vector and ArrayList. From what I can understand Vector is obsolete compared to ArrayList. But Vector is synchronized whilst ArrayList is not.

But what does that mean? What does it mean when we say that a Vector is synchronized? And when is this useful?

like image 493
jamietelin Avatar asked Apr 29 '12 23:04

jamietelin


1 Answers

It means that multiple threads can modify the Vector in parallel without risk of data corruption.

If you want to do this with an ArrayList, you need to use the synchronized keyword.

like image 122
Taymon Avatar answered Oct 08 '22 22:10

Taymon