The teacher has sent something, you have to queue up to receive it, Java synchronized keyword

When I was a child, when the teacher sent something, he asked us to line up one by one not to grab it, or we would get spanked. This scenario of multiple people queuing up to receive things is very similar to the scenario in which multiple threads access shared resources in programming. Today we combine the Java synchronized keyword to explain. ...

Posted by eastcoastdubs on Tue, 24 May 2022 03:06:35 +0300

volatile,synchronized visibility, orderliness, atomic code proof (basic hard core)

0. Introduction The previous article "Synchronized Usage Principles and Lock Optimization Upgrade Process" analyzes the synchronized keyword principle in detail from the perspective of interviews. This article mainly focuses on the volatile keyword and uses code to analyze visibility, atomicity, ordering, and synchronized also assists ...

Posted by joejoejoe on Sat, 30 Apr 2022 00:15:00 +0300

[advanced notes on Java basics] - Day06 - Chapter 2 thread safety

Advanced notes on Java Basics - Day06 - Chapter 2 thread safety System: Win10 JDK: 1.8.0_121 IDE: IntelliJ IDEA 2017.3.7 2.1 thread safety If there are multiple threads running at the same time, these threads may run this code at the same time. The result of each run of the program is the same as that of single thread, and the value ...

Posted by MadnessRed on Sat, 26 Mar 2022 06:01:57 +0300