"Java multithreaded" thread-safe Integer,automicinteger

Source: Internet
Author: User

Atomicinteger, a class that provides an integer for atomic manipulation. In the Java language, ++i and i++ operations are not thread-safe and, when used, will inevitably use the Synchronized keyword. The Atomicinteger is a thread-safe plus-minus operation interface.

Java.util.concurrent.atomic.AtomicInteger class, concurrent package belonging to Java


The class method is as follows:

/** to see the interfaces provided by Atomicinteger.  *//Get current value public final int get ()//Take current value and set new value public final int getandset (int newvalue)//Get current value and increment public final int Getandincrement ()//Gets the current value and subtract public final int getanddecrement ()//Gets the current value, plus the expected value public final int getandadd (int delt A



This article is from the architect's path blog, so be sure to keep this source http://lizhuquan0769.blog.51cto.com/2591147/1787174

"Java multithreaded" thread-safe Integer,automicinteger

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.