本文介绍了java.util.Vector - 替代品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以前我一直认为当长度未知时,Vector可以用于非描述对象。据我所知,我认为它也是线程安全的
Previously I would always have thought a Vector was good to use for non-descript objects when length was unknown. As far as I was aware I thought it was thread-safe too
什么会改变 Vector
不应该是否可以使用?
What would change that Vector
shouldn't be used anymore, and what is the alternative?
推荐答案
你应该使用 ArrayList
而不是 Vector
。 Vector
使用了内部同步,但这对于实际的一致性来说很少有用,并且只在不需要时才会减慢执行速度。
You should use ArrayList
instead of Vector
. Vector
used internal synchronisation, but that is rarely good enough for actual consistency, and only slows down execution when it is not really needed.
另见 。
这篇关于java.util.Vector - 替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!