談一談Vector類
阿新 • • 發佈:2019-03-05
repl tor nbsp java ace sequence arr -i https
4.即使要線程安全,通常也不用Vector,因為:
Vector synchronizes on each individual operation. That‘s almost never what you want to do. Generally you want to synchronize a whole sequence of operations. you can decorate a collection using the calls such as Collections.synchronizedList. ---- 摘自 https://stackoverflow.com/questions/1386275/why-is-java-vector-and-stack-class-considered-obsolete-or-deprecated
參考資料:
1)https://docs.oracle.com/javase/tutorial/collections/implementations/list.html
2)https://www.jianshu.com/p/a20052ac48f1
3)https://stackoverflow.com/questions/1386275/why-is-java-vector-and-stack-class-considered-obsolete-or-deprecated
4)https://blog.csdn.net/shecanwin/article/details/70846690
1.從 Java 2 平臺 v1.2 開始,vector類改進為實現 List 接口,成為 Java Collections Framework 的成員。所以vector類有一些遺留的方法。
2.Vector特點:線程安全的,因為很多方法都是同步方法。
3.Oracle官方文檔:
If you need synchronization, a Vector will be slightly faster than an ArrayList synchronized with Collections.synchronizedList. But Vector has loads of legacy operations, so be careful to always manipulate the Vector with the List interface or else you won‘t be able to replace the implementation at a later time. ----摘自 https://docs.oracle.com/javase/tutorial/collections/implementations/list.html
4.即使要線程安全,通常也不用Vector,因為:
Vector synchronizes on each individual operation. That‘s almost never what you want to do. Generally you want to synchronize a whole sequence of operations. you can decorate a collection using the calls such as Collections.synchronizedList. ---- 摘自 https://stackoverflow.com/questions/1386275/why-is-java-vector-and-stack-class-considered-obsolete-or-deprecated
參考資料:
1)https://docs.oracle.com/javase/tutorial/collections/implementations/list.html
2)https://www.jianshu.com/p/a20052ac48f1
3)https://stackoverflow.com/questions/1386275/why-is-java-vector-and-stack-class-considered-obsolete-or-deprecated
4)https://blog.csdn.net/shecanwin/article/details/70846690
談一談Vector類