Implementation of all functions in ArrayList are not synchronized.It is not thread safe.So It is a developer (who will use ArrayList class) responsibility to handle thread safety.
But Vector is synchronized one.So its a thread safe.
Subscribe to:
Post Comments (Atom)
@ Anai.. Nice reason to start a blog. keep them coming. Yeah vectors are thread safe. but looping using VectorInstance.getSize() and VectorInstance.get(i) is not. It is not thread safed on the structure of the vector. In other words, simultaneous modifications on the structure can occur. So a better and a more thread safe way is to use iterators
ReplyDeleteYa..its right.Especially in case of collection framework its always better to use iterators and foreach than normal loops.
ReplyDelete