Home > Java > javaTutorial > body text

Recommend 10 articles about Java memory model

伊谢尔伦
Release: 2017-06-12 11:28:32
Original
1573 people have browsed it

1. Analysis and overview of relevant concepts of the memory model. Three concepts in concurrent programming. Java memory model. In-depth analysis of the scenarios in which the volatile keyword is used. 2. Related concepts of the memory model. Cache consistency issues. Variables that are accessed by multiple threads are usually called shared variables. In other words, if a variable is cached in multiple CPUs (usually occurs in multi-threaded programming), then there may be a cache inconsistency problem. In order to solve the problem of cache inconsistency, there are usually two solutions: adding LOCK# to the bus and using the cache consistency protocol. These two methods are both provided at the hardware level. There is a problem with method 1 above. During the period of locking the bus, other CPUs cannot access the memory, resulting in low efficiency. Cache coherence protocol. The most famous one is Intel's MESI protocol, which ensures that the copy of shared variables used in each cache is consistent. Its core idea is: when the CPU writes data, if it finds that the variable being operated is a shared variable, that is, a copy of the variable also exists in other CPUs, a signal will be sent to notify other CPUs to set the cache line of the variable to None

1. Analyze the sample code of Java volatile keyword implementation from the root (picture)

Recommend 10 articles about Java memory model

Introduction: 1. Overview of analysis, related concepts of memory model, three concepts in concurrent programming, Java memory model, in-depth analysis of volatile keyword, scenarios of using volatile keyword, 2. Related concepts of memory model, cache consistency issue . Variables that are accessed by multiple threads are usually called shared variables. In other words, if a variable is cached in multiple CPUs (usually occurs in multi-threaded programming), then there may be a cache inconsistency problem. In order to solve the problem of cache inconsistency, there are usually two solutions: By adding LOCK# to the bus..

2. JMM java memory model graphic and text Detailed explanation

Recommend 10 articles about Java memory model

Introduction: JMM is inevitable for a programmer who wants to understand Java in depth First, this article is more theoretical, and I try to make it as easy to understand as possible. If there are any mistakes, I hope you can correct me.

3. Java String Overview (Part 2)

Recommend 10 articles about Java memory model

##Introduction: The String class in Java is the most frequently used class in our daily development, but it is not easy to truly master this class. In order to restore the true and complete picture of the String class, the author first divides it into two blog posts to review the String class. The author starts from the Java memory model, combined with the source code of the String class in the JDK, especially the constant pool, immutability, object creation method of the String class, the relationship between the String class and flyweight mode, regular expressions, cloning and the three major strings. A comprehensive and accurate explanation of several aspects such as categories.

4. Java String Overview (Part 1)

Recommend 10 articles about Java memory model

Introduction: The String class in Java is the most frequently used class in our daily development, but it is not easy to truly master this class. In order to restore the true and complete picture of the String class, the author first divides it into two blog posts to review the String class. The author starts from the Java memory model, combined with the source code of the String class in the JDK, especially the constant pool, immutability, object creation method of the String class, the relationship between the String class and flyweight mode, regular expressions, cloning and the three major strings. A comprehensive and accurate explanation of several aspects such as categories.

5. Detailed introduction to Java memory model

Recommend 10 articles about Java memory model

Introduction: This Java memory model specifies how the Java virtual machine works with computer memory (RAM). This Java virtual machine is a model of the entire computer, so that this model naturally includes a memory model - also called the Java memory model. Understanding the Java memory model is important if you want to design concurrent programs correctly. This Java memory model refers to how and when different threads can see the values ​​of shared variables written by other threads, and how to access shared variables synchronously. The original Java memory model was insufficient

6. [Fighting Java Concurrency]-----Analysis of Java Memory Model volatile

Recommend 10 articles about Java memory model

Introduction: The previous blog [Fighting Java Concurrency] - In-depth analysis of the implementation principle of volatile has already explained the characteristics of volatile: volatile Visibility; for a volatile read, you can always see the final write to this variable; volatile atomicity; volatile is atomic for a single read/write (32-bit Long, Double), but except for compound operations, such as i++; JVM The bottom layer uses "memory barrier" to implement volatile semantics. Below, LZ uses happens

7. [Fighting Java Concurrency]-----Reordering of Java Memory Model

Recommend 10 articles about Java memory model

Introduction: When executing a program, in order to provide performance, processors and compilers often modify instructions Reordering, but you cannot reorder at will. You can't sort it however you want. It needs to meet the following two conditions: 1. The result of program running cannot be changed in a single-threaded environment; 2. Reordering is not allowed if there are data dependencies. Sorting If you have read LZ’s previous blog, you will know that these two points can actually be attributed to one thing: it cannot be deduced through the happens-before principle, and JMM allows arbitrary sorting. as-if-serial semantics as-if-se

##8. 【Java concurrency】-----Java memory model happens-before

Recommend 10 articles about Java memory model

Introduction: In the previous blog ([Fighting Java Concurrency] - In-depth analysis of the implementation principle of volatile) LZ mentioned It has been seen that due to the existence of thread local memory and main memory, coupled with reordering, there will be visibility problems in multi-threaded environments. So if we use synchronization and locking correctly, when does thread A modify variable a visible to thread B? We cannot stipulate in all scenarios when variables modified by a thread are visible to other threads, but we can specify certain rules. This rule is happens-before. Starting from JDK 5, JMM uses ha

9. A brief analysis of Java memory model and garbage collection

Recommend 10 articles about Java memory model

Introduction : The editor below will bring you a brief analysis of Java memory model and garbage collection. The editor thinks it’s pretty good, so I’d like to share it with you now and give it as a reference. Come and have a look with the editor, I wish you all a happy game

10. In-depth analysis of Java memory model: basic part

Recommend 10 articles about Java memory model

Introduction: In concurrent programming, we need to deal with two key issues: how to communicate between threads and how to synchronize between threads (the threads here are Refers to concurrently executing active entities). Communication refers to the mechanism by which threads exchange information. In imperative programming, there are two communication mechanisms between threads: shared memory and message passing.

[Related Q&A recommendations]:

happens-before semantic order issues of java memory model

Multi-threading - Questions about Java memory visibility

The above is the detailed content of Recommend 10 articles about Java memory model. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!