In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Java memory model technology how to understand, in response to this problem, this article details the corresponding analysis and solutions, hoping to help more small partners who want to solve this problem to find a simpler and easier way.
Because Java memory model is not only Java focus to learn technical knowledge, or interview classic interview questions, hope to cause the attention of students, today's knock Ding Wolf training teachers to share Java memory model related technical knowledge.
Memory models vary from channel to channel, but jvm memory model standards are consistent. In fact, Java's multi-thread concurrency problem will be reflected in Java's memory model, the so-called thread safety is nothing more than to control multiple threads to visit or modify a certain resource in an orderly manner. Summing up Java's memory model, there are two primary problems to solve: visibility and orderliness.
Visibility: Multiple threads cannot communicate with each other, and communication between them can only be carried out through shared variables. The Java Memory Model (JMM) specifies that jvm has main memory, which is shared by multiple threads. When a target is new, it is also allocated in main memory. Each thread has its own job memory. Job memory stores copies of some targets in main memory. Of course, the job memory size of threads is limited. When a thread operates on a target, the order of execution is as follows:
(1)From main memory copy variable to current job memory (read and load)
(2)Fulfill code, change shared variable value (use and assign)
(3)Overwrite main memory related content with job memory data (store and write)
When a shared variable has copies in job memory of multiple threads, if one thread modifies the shared variable, then the other threads should see the modified value, which is the visibility problem of multithreading.
Orderability: A thread cannot quote a variable directly from main memory, if the variable is not in the thread's job memory, it copies a copy from main memory to job memory, and the thread will quote the copy when it is finished. When the same thread references the field again, it is possible to retrieve the read-load-use from memory, or it is possible to reference the original use directly, that is, the order of read,load,use can be determined by the JVM completion system.
A thread cannot assign values directly to fields in main memory, it assigns values to a variable copy in job memory (assign), and when complete, this variable copy is synchronized to the main store (store-write), and when synchronization occurs depends on the JVM completion system decision. If there is this field, it will be assigned from main memory to job memory. This process is read-load. After completion, the thread will quote a copy of this variable.
About Java memory model technology how to understand the answer to the problem shared here, I hope the above content can be of some help to everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.