Java concurrency Programming underlying implementation principle-volatile

Source: Internet
Author: User

The definition of volatile in the third edition of the Java Language specification is as follows:

The Java programming language allows threads to access shared variables, and in order to ensure that shared variables can be updated accurately and consistently, the thread should ensure that an exclusive lock

Get this variable separately.

Volatile is sometimes more convenient than a lock, such as a field that is declared as a Volatile,java thread memory model to ensure that all threads see this variable

The values are consistent.

How does volatile ensure visibility? When you need to see the Java code translated into assembly code, the process of implementation can refer to the art of Java concurrent programming

Chapter II, or other information. (Mostly I'm not familiar with the assembly)

It also involves the principle of CPU and memory and its caching.

It technology and industry exchange Group 417691667

Java concurrency Programming underlying implementation principle-volatile

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.