Vector, ArrayList, HashTable, HashMap哪些是线程安全的,哪些不是
2023-07-06
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来包装一下才能实现同步。