一位同事说,不使用java.util.Vector中了 - 为什么不呢? [英] A colleague said don't use java.util.Vector anymore - why not?

查看:484
本文介绍了一位同事说,不使用java.util.Vector中了 - 为什么不呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆