Synchronization in Vectors in Java

前端 未结 4 997
独厮守ぢ
独厮守ぢ 2021-01-04 21:08

what is meant by vector in Java is thread safe and synchronized, how is it made thread safe. I\'m looking at internal details of implementation

4条回答
  •  不知归路
    2021-01-04 21:42

    Vector is considered 'thread-safe' because access the the internals of the Vector is synchronized. Methods such as add(), get(), size(), etc, are all synchronized such that modifications to the internal structure of the Vector and access to that internal structure cannot be processed simultaneously by separate threads.

提交回复
热议问题