Java Concurrency Atomicintegerarray class

Source: Internet
Author: User

java.util.concurrent.atomic.AtomicIntegerArrayThe class provides an operation for the underlying array that can be read and written atomically int , and also contains advanced atomic operations. AtomicIntegerArraysupports int atomic manipulation of underlying array variables. 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 follow-up on the same variable get . Atomic compareAndSet methods also have these memory-consistency features.

Serial Number Method Description
1 public int addAndGet(int i, int delta) Atomically adds the given value to the indexed i element.
2 public boolean compareAndSet(int i, int expect, int update) If the current value is == expected, the i element atom at the location is set to the given update value.
3 public int decrementAndGet(int i) ithe element at the index is atomic and self-decreasing 1 .
4 public int get(int i) Gets i The current value of the position.
5 public int getAndAdd(int i, int delta) Atomically adds the given value to the indexed i element.
6 public int getAndDecrement(int i) ithe element at the index is atomically and is self 1 -decrement, and the old value is returned.
7 public int getAndIncrement(int i) isets the atom of the element at the location to the given value and returns the old value.
8 public int getAndSet(int i, int newValue) isets the atom of the element at the location to the given value and returns the old value.
9 public int incrementAndGet(int i) Atomically increases the element at the index i .
10 public void lazySet(int i, int newValue) Finally, the i element at the location is set to the given value.
11 public int length() Returns the length of the array.
12 public void set(int i, int newValue) isets the element at the location to the given value.
13 public String toString() Returns the representation of the current value of the array String .
14 public boolean weakCompareAndSet(int i, int expect, int update) If the current value is == expected, the i element atom at the location is set to the given update value.
Example

Following

Click on the link to view the details

Java concurrency Atomicintegerarray 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.