Java copyonwritearraylist Analysis

Source: Internet
Author: User

Copyonwritearraylist is a thread-safe ArrayList, as the name implies, it will take advantage of the write-time copy technology, it to the shared object to do a read-only operation, we all use a shared object, assuming that there is a variable operation, it will be copied a copy out, Then operate on the new copy.


Therefore, the cost of the variable operation will be larger, of course, before running the replication, the need for an exclusive lock, so that when the replication, there will be no inconsistency, after the replication is complete, release the lock. While doing replication, other threads are able to perform only read operations on older objects, so they do not clog the read operation.


When replication runs out, change the volatile reference so that other threads can see the latest changes.

Original: http://blog.csdn.net/hongchangfirst/article/details/39668723

Author: Hongchangfirst

Hongchangfirst's homepage: http://blog.csdn.net/hongchangfirst


Java copyonwritearraylist Analysis

Related Article

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.