Java Concurrency Atomicreferencearray class

Source: Internet
Author: User

java.util.concurrent.atomic.AtomicReferenceArrayThe class provides an operation of the underlying reference array that can be read and written by Atoms, and also contains advanced atomic operations. AtomicReferenceArraysupports atomic manipulation of the underlying reference array variable. It has a get and set method, such as read and write on a variable. In other words, a collection is associated with any subsequent fetch on the same variable. Atomic compareAndSet methods also have these memory-consistency features.

Atomicreferencearray Method

The following is a AtomicReferenceArray list of the important methods available in the class.

sequence Method Description
1 public boolean compareAndSet(int i, E expect, E update) If the current value is == expected, the i element atom at the location is set to the given update value.
2 public E get(int i) Gets i The current value of the position.
3 public E getAndSet(int i, E newValue) isets the atom of the element at the location to the given value and returns the old value.
4 public void lazySet(int i, E newValue) Finally, the i element at the location is set to the given value.
5 public int length() Returns the length of the array.
6 public void set(int i, E newValue) isets the element at the location to the given value.
7 public String toString() Returns the representation of the current value of the array String .
8 public boolean weakCompareAndSet(int i, E expect, E update) If the current value is == expected, the i element atom at the location is set to the given update value.
Example

Click on the link to view the details

Java Concurrency Atomicreferencearray class

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.