Vector, ArrayList, HashTable, HashMap哪些是线程安全的?哪些不是?

匿名网友 匿名网友 发布于: 2015-08-30 00:00:00
阅读 157 收藏 0 点赞 0 评论 0

Vector and Hashtable are two collection classes that are inherently thread safe or synchronized; whereas, the classes ArrayList and HashMap are unsynchronized and must be `wrapped` via Collections.SynchronizedList or Collections.synchronizedMap if synchronization is desired.

Vector和Hashtable是线程安全的,ArrayList和HashMap不是线程安全的而且必须要通过Collections.SynchronizedList或者Collections.synchronizedMap来包装一下才能实现同步。

评论列表
文章目录