MindMap Gallery JAVA review key points
This is a mind map about the key points of review, including ACticiti workflow, multi-threading, etc. It’s full of useful information, friends in need should quickly collect it!
Edited at 2023-12-21 17:34:50This Valentine's Day brand marketing handbook provides businesses with five practical models, covering everything from creating offline experiences to driving online engagement. Whether you're a shopping mall, restaurant, or online brand, you'll find a suitable strategy: each model includes clear objectives and industry-specific guidelines, helping brands transform traffic into real sales and lasting emotional connections during this romantic season.
This Valentine's Day map illustrates love through 30 romantic possibilities, from the vintage charm of "handwritten love letters" to the urban landscape of "rooftop sunsets," from the tactile experience of a "pottery workshop" to the leisurely moments of "wine tasting at a vineyard"—offering a unique sense of occasion for every couple. Whether it's cozy, experiential, or luxurious, love always finds the most fitting expression. May you all find the perfect atmosphere for your love story.
The ice hockey schedule for the Milano Cortina 2026 Winter Olympics, featuring preliminary rounds, quarterfinals, and medal matches for both men's and women's tournaments from February 5–22. All game times are listed in Eastern Standard Time (EST).
This Valentine's Day brand marketing handbook provides businesses with five practical models, covering everything from creating offline experiences to driving online engagement. Whether you're a shopping mall, restaurant, or online brand, you'll find a suitable strategy: each model includes clear objectives and industry-specific guidelines, helping brands transform traffic into real sales and lasting emotional connections during this romantic season.
This Valentine's Day map illustrates love through 30 romantic possibilities, from the vintage charm of "handwritten love letters" to the urban landscape of "rooftop sunsets," from the tactile experience of a "pottery workshop" to the leisurely moments of "wine tasting at a vineyard"—offering a unique sense of occasion for every couple. Whether it's cozy, experiential, or luxurious, love always finds the most fitting expression. May you all find the perfect atmosphere for your love story.
The ice hockey schedule for the Milano Cortina 2026 Winter Olympics, featuring preliminary rounds, quarterfinals, and medal matches for both men's and women's tournaments from February 5–22. All game times are listed in Eastern Standard Time (EST).
Review points
JVM
escape analysis
Not all new objects will allocate memory in the heap. If a new new object is analyzed by the virtual machine and will not be referenced elsewhere except within the scope of the method, then the object will allocate memory on the stack.
There is a size limit for objects allocated on the stack. If it is a large object, it will also be allocated on the heap.
When Java code is running, you can specify whether to enable escape analysis through JVM parameters.
-XX: DoEscapeAnalysis: Indicates turning on escape analysis
-XX:-DoEscapeAnalysis: Indicates turning off escape analysis. Escape analysis has been started by default since jdk 1.7. If you want to turn it off, you need to specify -XX:-DoEscapeAnalysis.
Parental delegation model
If we want to implement a custom class loader, we must first inherit the ClassLoader class in the JDK. If we want to break the parental delegation model, we must rewrite its loadClass method; if we want to follow the parental delegation model, we just implement a custom class loader. To load the path, we just need to override findClass
When rewriting findClass, there is a core method defineClass, which can convert a byte array into a Class object. This byte array is the final byte array after reading the .class file. In other words, we only need to pass the file stream bytes The stream FileInputStream reads in the byte stream in the .class file, and then deserializes it into a Class object through defineClass.
Commercial source code Class file encryption
The generated Class bytecode file is encrypted and decoded when reading the byte stream.
Garbage collection algorithm
reference counting
mark-and-sweep
What are GC Roots
GCRoots are the starting point of the reference chain, leading to the next node they point to, which is usually an object whose life cycle is consistent with the JVM.
Those objects can be used as GC Roots 4 types
Virtual machine stack -----Objects referenced in the local variable table in the stack frame
Native method stack ----- Generally speaking, the object referenced by the Native method
The object referenced by the class static property in the method area
Objects referenced by constants in the method area
Garbage collector
run around
Serial
If garbage collection takes too long, the STW time will also be longer, affecting throughput.
concurrent
Parallel Scavenge (copy recycling of the new generation) / Parallel Old (mark scavenging of the old generation)
You can specify the time for garbage collection. If it is too long, garbage collection will be stopped and the user thread will be executed. But correspondingly, the number of garbage collections will also increase, resulting in too long STW time and affecting throughput.
parallel
Parallel NEW (copy recycling in the new generation) / CMS (mark clearing in the old generation)
CMS garbage collector divides the garbage collection process into 5 steps
Initialization mark (CMS-initial-mark): Marking the objects directly related to the root will cause stw, but there are not many objects and the time is short.
Concurrent mark (CMS-concurrent-mark): Follow the root of the previous step and trace down. This step takes the longest, but it runs at the same time as the user thread.
Three color markings: black, white, gray
Black: Indicates that the object and the attributes under the object have all been marked. (Objects needed by the program should not be recycled) Gray: The object is marked, but the properties under the object are not completely marked. (Need to find garbage in this object) White: Object is not marked (garbage that needs to be cleared)
Remark (CMS-remark): Because the previous step is performed concurrently, if there are changes in the incremental step, it will cause STW, but it will be much less than the previous step.
Concurrent sweep (CMS-concurrent-sweep): Kill the marked ones. Because it is a mark-sweep algorithm, there is no need to move surviving objects, so this step runs at the same time as the user thread.
Reset thread: reset the state and wait for the next CMS trigger (CMS-concurrent-reset), running at the same time as the user thread
CMS Garbage Collector Disadvantages
JMM Java Memory Model
Main memory and working memory
JMM stipulates that all variables are stored in main memory (Main Memory)
Each thread also has its own working memory (Working Memory), which retains a copy of the main memory of the variables used by the thread.
All operations on variables by threads must be performed in working memory, and variables in main memory cannot be directly read and written. Different threads cannot directly access the variables in each other's working memory. The transfer of variable values between threads needs to be completed through the main memory.
i =1
This command contains three steps
Call load to load variables from main memory to working memory
Variable = variable 1 performs assignment operation
Call store to write the value of the variable from the working memory to the main memory.
non-atomic operations
What problem does JMM solve?
Working memory data consistency: visibility issues
Constrained instruction reordering optimization: ordering problem
JMM memory interaction
JMM defines 8 operations to complete the interaction between main memory and working memory
Happens-Before
1. program sequence rules
This rule means that in a thread, according to the program order (possibly the order after reordering), the previous operation happens-before any subsequent operation. The modification of a variable in the front of the program must be visible to the subsequent operations. of
2. volatile variable rules
This rule refers to a write operation to a volatile variable. Happens-Before subsequent read operations to this volatile variable.
3. Rules for locking in monitors
Unlocking a lock Happens-Before subsequent locking of the lock
Monitors (also known as monitors) are a general synchronization primitive that can achieve mutually exclusive access to shared resources. In Java, it refers to synchronized, which is the implementation of monitors in Java.
4. Thread startup rules
It means that after main thread A starts sub-thread B, sub-thread B can see the operations of the main thread before starting sub-thread B.
5. Thread join rules
It means that the main thread A waits for the sub-thread B to complete (the main thread A realizes it by calling the join() method of the sub-thread B). When the sub-thread B completes (the join() method in the main thread A returns), the main thread can see Operation to child thread. Of course, the so-called "seeing" refers to the visible operation results of shared variables.
6. Thread interruption rules
Calling the thread interrupt() method Happens-Before The code of the interrupted thread detects the occurrence of the interrupt event. For example, we can detect whether an interrupt occurs through the Thread.interrupted()/isInterrupted method.
Thread.interrupted() will clear the interrupt flag bit, but isInterrupted will not
7. Object finalization rules
The completion of initialization of an object (the end of constructor execution) occurs first at the beginning of its finalize() method.
When final modifies a variable, the original intention is to tell the compiler that this variable is immutable and can be optimized. After 1.5, the Java memory model restricts the rearrangement of final type variables. Now as long as we provide the correct constructor without "escaping", there will be no problem.
For object escape issues, do not assign objects to external variables in the constructor. It is possible that the properties of the object have not been initialized yet.
jvm lock upgrade process
No lock -> Biased lock -> Lightweight lock -> Heavyweight lock
The bias lock is not turned on immediately by default. The bias lock will be turned on 4 seconds after the jvm is started. Or it can be started immediately through the command -XX:BiasedLockingStartupDelay=0
lock roughening, lock elimination
JDK source code
1.Object class
Any class inherits from the Object class: inherits the Object class at compile time
By decompiling the bytecode file through javap, you can see in jdk6 that the declaration inherited from is displayed during compilation. Object, and after jdk8, you can see the method of initializing Object
native keyword
jni means that it is not implemented through java code, but through c/c Implemented, native is just a pointer, pointing to the file in the .dll dynamic library
toString()
equals()
Five principles for overriding the equals method
1. Reflexivity: x.equals(x) = true
2. Symmetry: x.equals(y) = true, then y.equals(x) = true
3. Transitivity: x.equals(y) = true, y.equals(z)=true, then z.equals(x) must also be equal to true
4. Consistency: x.equals(y)=true, then it is still true no matter how many times it is called
5. For any non-null reference x, x.equals(null) must return false
hashcode()
Overriding the equals method, why must we override the hashcode method?
General conventions for maintaining hashcodes: equals is equal, then the hashcode must be equal hashcode is equal, equals is not necessarily equal
Improve the efficiency of comparing elements in the collection. When a hash collision occurs, the equals method needs to be called.
The hashcode method is mainly to improve the speed of search and positioning. One hash calculation can accurately locate the subscript position.
Object composition
Object header (8 bytes): GC generation age, lock flag, hashcode value
Generational age only occupies 4 bits, and the maximum value that 4 bits can represent is 16. Therefore, in the new generation If an object survives 16 Minor GCs, it will enter the old generation.
Object header type pointer (4 bytes)
Real column data
Byte padding: the bytes occupied by the object must be a multiple of 8
Generate hashcode
For a newly created object, the hashcode value will not be recorded in the object header.
When the hashcode method is called, the hashcode value will be recorded in the object header.
If it is currently in a biased lock state, due to limited space in the object header, if you want to record the hashcode value, you need to cancel the biased lock first, because the current mark work is stored in the current biased lock and holds the current thread ID, free up space, and then Calculate the hashcode value and return it. At this time, the lock will be changed from a biased lock to a heavyweight lock.
After an object calls the native hashCode method (from Object, which has not been overwritten), the object will not be able to enter the biased lock state, and will start as a lightweight lock. If the hashCode method is called when the object is already in a biased lock state, its biased state will be revoked immediately and the lock will be upgraded to a heavyweight lock.
Biased lock needs to record thread ID, production The hashcode has no space to record the biased lock thread ID. So it will be upgraded
If it is a lightweight lock or heavyweight lock, the hashcode value will be placed in the current mark work and stored in the monitor object pointed to by the object pointer.
For lock-free object headers, the preference should be canceled first. If it is light, look for the helper. If it is heavy, look for the monitor.
getCLass()
clone()
Shallow cloning and deep cloning
Shallow cloning: reference type clones the same address value
finalize()
When the GC determines that the object is no longer referenced, it will call the finalize method to clear the recycling The JVM will ensure that the finalize() method is only called once, and the program cannot directly call the finalize() method.
2.Data structure
ArrayList class
Data structure: array (continuous storage space)
Features: Fast search, slow addition and deletion
initialization
Before JDK7, when initialized, an array of length 10
When JDK8 is initialized, the bottom layer is an empty array.
Arraylist is expanded to the original array length and the original array length is shifted to the right by one position (divided by 2)
add method
When constructed without parameters
Initial capacity is 10
Structure with parameters
When the initial capacity is less than 10, add one each time
When it is greater than 10, each expansion will shift one bit to the right.
remove method
Call the System.copy method to copy yourself (shallow copy) and assign the last bit to null
LinkedList
Data structure: doubly linked list
Features: Fast addition and deletion, slow query
HashMap
Data structure: Hash table
Store data in key-value format
The initial capacity is 16 which must be a power of 2 and the loading factor is 0.75
Why is capacity a power of 2? Because when the key is hashed, it needs to be ensured that the recalculated value is within the capacity range. The AND operation is more efficient than the modular operation. The bottom layer of the source code will perform the AND operation of capacity -1. If it is not a power of 2, it will cause Half the space is wasted
When the number of elements = capacity * loading factor, expansion will be triggered The reason for 0.75 is that there is a balance between space and time, that is, there will be no frequent expansion, and there will be no frequent hash collisions that cause a certain linked list to be too long.
The implementation of header interpolation in JDK 1.7 version is to create a new Entry and point the next pointer of the Entry to the original [ ]Entry collection.
In JDK1.7, when calculating the key, it will be disturbed 7 times, while JDK1.8 will only be disturbed twice. The perturbation is only to allow the high bits to participate in the calculation and improve the discreteness.
Four attributes of Entry object: hash, key, value, next
In JDK1.7, it will be added first and then expanded, while in JDK1.8 it will be expanded first and then added. After adding elements, it will be judged whether there are more than 8 nodes. If the list nodes exceed 8 and the number of elements exceeds 64, it will be converted into red and black. Tree, when the number of list nodes is less than or equal to 6, the tree will be converted into a linked list.
HashMap in 1.8 uses the tail interpolation method, and 1.7 uses the head interpolation method to avoid loops (infinite loops) under concurrency. But there are still thread safety issues. HashMap itself is not a thread-safe class
hashtable
Each method is decorated with sync
The lock granularity is too large and multi-threading is not supported.
concurrenthashmap
segment lock
Composed of segments, each segment is similar to a hashMap Once a segment is initialized, it cannot be added, and the underlying The emtry[ ] array can be expanded
The number of segments in concurrentHashMap determines the maximum number of concurrencies supported by concurrentHashMap.
Let’s talk about concurrentHashMap and compare it with HashTable HashTable locks the entire array, while concurrentHashMap Divide the array into segments. Each time you lock, you lock one segment. Each segment contains an entry[ ] array, and each entry[ ] array is equal to a hashmap
concurrentHashMap needs to calculate the subscript position twice. First determine whether the element should be On which segment, and then hash calculation again to determine which index it should be placed on Then judge whether expansion is needed and whether treeing is needed.
How to be thread safe
Implement CAS through the Unsafe class to create a segment object, and then create a node node (1.7 is an array)
1.7
Initialize the segment array (must be 2 to the nth power), and then instantiate segment[0] through cas segment object, used to store information about instantiating other segments in the future, such as the length of the entry[] array The lock is loaded on the entry array through the trylock() method
1.8
Compared with 1.7, in jdk1.8, linked list red-black tree is used, the lock is loaded on the node linked list, and the lock object It is the head node of the node linked list, and the lock granularity is finer than 1.7.
The reason why HashTable and ConcurrentHashmap do not allow the key to be null
Avoid ambiguity: In a multi-threaded environment, it is not known that null is stored. Still not getting the value as null
Because ConcurrentHashMap is thread-safe, it is generally used in a concurrent environment. After you first get null in the get method, and then call the containsKey method, there is no way to ensure that there are no other threads between the get method and the containsKey method to cause trouble. The object you want to query has been set or deleted.
sync
characteristic
atomicity
consistency
visibility
Unfair lock, keyword
usage
Method declaration - synchronized method
synchronized code block
The underlying implementation based on the monitor monitor is recorded in the object header mark word. The memory address of the monitor object, and the monitor object has two important attributes count, own count records the number of reentrants of the lock, and own records the thread id. When executing a synchronization method, own will first record whether the thread ID is the current thread or not. Then determine whether count is equal to 0, if it is equal to 0 Just assign yourself as the thread id to own If not, block and wait
monitor object
Each object will have a corresponding monitor object corresponding to it
Monitor object composition
count records the number of lock reentries
owner records the thread ID currently holding the lock
waitset Threads in the wait state of the lock will be added to this queue.
Entrylist Threads that are blocked and waiting for the lock block will be added to this queue.
The difference between wait and sleep: 1.sleep is a method of thread class Thread, and wait is a method of Object 2.wait will release the lock, but sleep will not release the lock. 3. The sleep state of the thread can be interrupted by calling the interrupt method. The wait state of the thread can be awakened through notify or notifyAll
High performance distributed cache
Redis (supports a large number of QPS)
Is Redis single-threaded?
Versions before 6.0
Before Redis version 6.0, network IO and data reading and writing were single-threaded. However, data persistence, asynchronous deletion, and inter-cluster data synchronization are multi-threaded. Data persistence will fork a sub-thread from the main thread for data persistence.
Versions after 6.0
In Redis versions after 6.0, network IO becomes multi-threaded, but it is also turned off by default and needs to be turned on manually.
Reason why Redis is fast:
Single thread to avoid the cost of maintaining multi-thread shared variables
Efficient index data structure: Hash skip table
Memory based operations
Multiple IO multiplexing
How do Mysql and Redis maintain data consistency?
Delayed double deletion (there will still be problems)
First delete the data in Redis, and then update the data in Mysql, with an interval of 3 to 5 seconds. Then delete the data in Redis
Monitor the bingLog message queue (guaranteed message percentage delivery)
Five common data types
String
Data structure: simple dynamic string (simple dynamic string) SDS
use:
Data cache
Distributed lock
Interface current limit
Hash
Data structure: When the amount of data is small, it is zipList; when the amount is large, it is Hash table
Purpose: cache objects
Advantages and Disadvantages:
advantage:
Compared with String, it saves more space
Reduces memory consumption more than String
Convenient storage of similar data
shortcoming:
Setting expiration can only be applied to the key and cannot be applied to a specific field.
Redis cluster is not suitable for large-scale use (a large number of requests access the same node)
List
Data structure: doubly linked list
use
Stack (first in, last out): lpush -> lpop
Queue (first in, first out): lpush -> rpop
Blocking queue: lpush -> brpop
Set
Data structure: Unordered non-repeating collection
use
Data deduplication
Take intersection, union, difference
Zset
Data structure: ordered set (increased weight parameters compared to set)
use
User rankings, hot news
bitmap bitmap
Data structure: continuous binary array
Lua script
Benefits of Lua scripting
Redis command execution is single-threaded, so there is no need to worry about the insertion of other commands, ensuring atomicity.
Lua scripts will be stored in Redis to improve reusability
Lua script commands
Generate Lua script
Eval
Data persistence
RDB snapshot
Trigger mode
manual trigger
save command
Will cause the current main thread to block
bgsave command
Fork a child process, and the child process performs data persistence. Therefore, it will only cause blocking when forking the process.
redis.conf configuration trigger
Persistence process: First trigger the fork sub-process, read the main process data, and generate a temporary file. When the reading is completed Rename the temporary file and replace the original .rdb file During the persistence process, if you need to execute the set command, copy-on-write technology will be used to copy a copy for the child process to read.
AOF diary
Triggering method: All commands will be appended to the AOF buffer, and then the AOF buffer will be written to the .aof file.
AOF rewriting: Since AOF persistence is persisted in the log method, it will inevitably cause the file to become larger and larger. Therefore, the aof file needs to be rewritten.
Hybrid persistence
Supported after Redis 4.0
AOF rewriting will be stored in the form of RDB, and subsequent commands will be recorded in the form of AOF logs.
When recovering data, .aof backup files take priority
Online experience:
In master-slave mode, generally the slave machine turns on persistence.
Develop your own data persistence strategy, check it regularly, and manually trigger backup and persistence
Try to enable hybrid persistence as much as possible
memory elimination algorithm
LRU
LRU algorithm object only records the timestamp of the last call
LFU
The LFU algorithm object records the timestamp of the last call and the number of calls. If the times are the same, compare the timestamps
High availability
master-slave mode
One master, many slaves
Multiple masters and multiple slaves (cluster)
After the slave machine establishes a connection with the master machine, it will first perform a full synchronization. The .RDB file is generated by the host and sent to the slave. During this period, the host receives New commands will be sent to the slave in the form of a buffer cache file. Completely received from the machine After the .RDB file and the cache file are loaded, their own data will be refreshed and cleared first, and then loaded from Files received by the host
Distributed lock
Mutual exclusivity: Not only are different threads in the same jvm process mutually exclusive, but different threads in different jvm processes must also be mutually exclusive.
Lock timeout: Supports automatic release of locks to prevent deadlocks
Correct unlocking: The lock added by that thread should be unlocked by which thread
Reentrant: After a thread acquires the lock, it can acquire the lock again without having to grab the lock.
Blocking/non-blocking: Direct return is non-blocking if it cannot be obtained. If the lock cannot be obtained, it will keep waiting for the lock, which is blocking.
Fair/Unfair: Lock acquisition is in order, and the first to fail grabs the lock first.
Problems caused by Redis
cache penetration
Add parameter verification to the interface
Cache empty values while setting a short expiration time
Introduce Bloom filter
Cache breakdown
cache avalanche
Use CLuster cluster to distribute hotspot data among different nodes
Add a random value when setting the expiration time for each key
Database expansion
Smooth database expansion
Dual-master mode, two mysql servers, each is a master and a slave, each other is a master-slave
Vertical expansion: A large amount of data will need to be migrated. If it is not migrated, the data will not be obtained by taking the modulus.
Expansion method
Downtime plan
Stop writing plan
Can't write, can only read
diary record
Asynchronous logging (addition, deletion and modification)
Data synchronization tool
Log incremental synchronization tool
Smooth 2N scheme
Set up a slave database for each master database to ensure the integrity of the slave database information. Then upgrade the slave library to the main library, and delete the records that should not be placed in this library (redundant data processing)
ACticiti workflow
Initialize 25 tables
1. General data table
2. Process history table
3. Process definition table
4. Run the real list
Five Services
process symbol
event
Activity
gateway
flow direction
Multithreading
Thread status
initialization
ready
block
wait
timeout wait
die
Thread Pool
Four thread pools encapsulated by Executors
FixedThreadPool fixed-length thread pool
Only core threads
ScheduledThreadPool scheduled thread pool
The waiting queue is DelayedWorkQueue(), an unbounded queue used to place objects that implement the Delayed interface. The objects in them can only be removed from the queue when they expire.
CachedThreadPool cache thread pool
There are no core threads, only non-core threads
SingleThreadExecutor single-threaded thread pool
Only one core thread
The difference between submit and execute
Submit can execute thread tasks that implement the Runable interface or the Callable interface.
The executor can only execute thread tasks that implement the Runable interface.
Interview questions
How does the thread pool ensure that threads are not destroyed?
If there is no task in the queue, the core thread will block in the task acquisition method until the task is returned. After the task is executed, it will enter the next round of work.runWork() loop. If it is a non-core thread, the non-blocking poll() method of the queue will be called, and it will try to obtain it within the set time. If it does not obtain it, the timeout status will be set to true.
So what state will the threads in the thread pool be in?
RUNNABLE,WAITING
Fork/Join
concept
Fork
Fork (bifurcation), first divide the large task into small enough subtasks, and if the subtasks are relatively large, continue to divide the subtasks.
Join
Join, after the divided subtasks are executed by multiple threads, the results are then merged to obtain the final complete output.
Atomic operations
CAS
Compare and replace is a technical subtopic commonly used to implement concurrency.
The main parameters
The current value
Expected value
new value
There is an ABA problem
Solve it using version number
AQS abstract queue synchronizer (template method pattern)
Implementing fair locks and unfair locks
fair lock
Go directly to grab the lock without checking whether there are threads in the waiting queue. If there are threads in the queue, wouldn't it become queue jumping, which will lead to unfairness.
unfair lock
First check whether there is anyone in the waiting queue. If there is, then queue up obediently and do not jump in line. If not, you can directly acquire the lock.
AQS uses a volatile int state; attribute to represent the lock status. 1 means the lock is held, 0 means not held. The specific maintenance is maintained by subclasses, but three methods are provided to modify this attribute: getState(), setState(int newState), compareAndSetState(int expect, int update), among which the CAS method is the core.
The framework maintains a FIFO waiting queue internally, which is implemented using a doubly linked list. We call it the CLH queue.
The framework also implements the condition variable Condition internally, using it to implement the waiting wake-up mechanism and supporting multiple condition variables.
AQS supports two modes of resource sharing: exclusive mode (Exclusive) and shared mode (Share). The so-called exclusive mode means that only one thread is allowed to access shared resources at any time, such as ReentrantLock; and the shared mode means that multiple threads are allowed to access at the same time. Shared resources, such as Semaphore/CountDownLatch
Users only need to inherit AbstractQueuedSynchronizer and rewrite the specified method to complete the acquisition and release of the shared resource state within the method. As for the maintenance of specific thread waiting queues, AQS has already been implemented at the top level. In those final template methods
Thread class
Sleep()
Pausing for a while only gives up the execution rights of the CPU without releasing the lock.
yield()
The lock is not released, and the CPU becomes ready during operation, allowing the CPU to compete with the same priority. Of course, it's possible to snatch it back yourself
join()
The parent thread waits for the child thread to complete before executing, turning asynchronous into synchronous.
Three major characteristics of threads
atomicity
visibility
Orderliness
issues that need resolving
CPU cache causing visibility issues Volatile
For the shared variable i, first read it from the memory to the CPU, and then perform related operations on it. If thread A modifies it, thread B can immediately see the result of thread A's operation. We call it It is the visibility between threads. In a single-core CPU architecture, all threads are executed on one CPU, because all threads operate the cache of the same CPU. One thread's write to the cache must be visible to another thread. But in the era of multi-core CPUs, each CPU has its own cache. When multiple threads are executed on different CPUs, these threads operate different CPU caches.
The Volatile keyword can solve the cache visibility problem. The cache line of the variable modified by it will be invalid in the working memory, and the current thread will go to the main memory to get the latest value.
Thread switching causes atomicity issues sync keyword and atomic class
Performance optimization leads to ordering issues Volatile
Double check lock to determine whether the object is empty, new is not atomic The memory address of the object already exists, but the properties are still initialized (execute init method)
Jenkins continuous inheritance
concept:
CI: Continuous Integration
CD: Continuous Delivery
Distributed transactions
message queue