一位同事说,不使用java.util.Vector中了 - 为什么不呢? [英] A colleague said don't use java.util.Vector anymore - why not?
问题描述
previously我总是会想到一个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
会有什么变化,它不应该再使用了,什么是另类?
What would change that it shouldn't be used anymore, and what is the alternative?
推荐答案
您应该使用的ArrayList
而不是矢量
。 矢量
使用的内部同步,但很少够用了实际的一致性,只有慢下来的时候是不是真的需要它的执行。
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.
另请参阅<一个href=\"http://stackoverflow.com/questions/1386275/why-java-vector-class-is-considered-obsolete-or-de$p$pcated\">this计算器问题。
这篇关于一位同事说,不使用java.util.Vector中了 - 为什么不呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!