Java thread-safe collection object and java thread set
Vector and ArrayList
Vector is thread-safe, but Vector is not used in most cases, because thread security requires greater system overhead.
HashTable and HashMap
Methods In Hashtable are synchronized, while those in HashMap are not synchronized by default. Hashtable can be used directly in a multi-thread concurrent environment, but you need to add synchronization to use HashMap.
StringBuilder and StringBuffer
The StringBuilder and StringBuffer methods are the same, that is, the former is multithreading while the latter is single-threaded.
Stack inherited from Vector is also thread-safe.
By using java. util. collections to create a thread-safe set, such as Connections. synchronizedSet (Set <T>); Connections. synchronizedList (List <T>); Connections. synchronizedMap (Map <K, V>). The simple principle is that synchronized is added to every method to ensure thread security.
It may not be complete.