Java synchronous container and concurrent container, java synchronous container concurrency
Synchronous container (reading and writing in concurrent iterations is NOT thread-safe)
- The class created by the static factory method of the Collections class (for example, Collections. synchronizedList)
- Synchronous implementation by adding synchronzied to all common methods of containers (poor performance in Concurrent Environments)
Concurrent containers (thread security) added in JDK 1.5)
- ConcurrentHashMap (instead of Map; uses the Segment structure internally to perform two Hash operations for location, and only locks the Segment when writing)
- CopyOnWriteArrayList (copy a new copy when writing CopyOnWrite, modify it on the new one, and then point the reference to the new one. Only the final consistency of data can be achieved, rather than real-time consistency; instead of List, applicable to read Operations)
- Concurrent1_queue (the difference between the queue and the list is that the queue can only operate on the data in the header and tail)
- PriorityQueue (non-concurrent)
- The two most common concurrent containers are ConcurrentHashMap and CopyOnWriteArrayList.
References: http://blog.csdn.net/basycia/article/details/52059732