Java synchronous container and concurrent container, java synchronous container concurrency

Source: Internet
Author: User

Java synchronous container and concurrent container, java synchronous container concurrency
 Synchronous container (reading and writing in concurrent iterations is NOT thread-safe) 

  • Vector, Stack, HashTable
  • 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)
  • BlockingQueue
  • The two most common concurrent containers are ConcurrentHashMap and CopyOnWriteArrayList.
References: http://blog.csdn.net/basycia/article/details/52059732

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.