1. Memory interaction process
Thread 1 updates the x value of the thread's working memory update to the main memory center line.
Read the x variable previously updated by thread 1 from thread 2 to main memory.
2. Eight kinds of interactive operations
lock(lock)
Acts on variables in main memory and marks the variables as thread-exclusive.
unlock(unlock)
Acts on variables in the main memory and releases the variables in the locked state. The released variables are locked by other threads.
read(read)
Acts on variables in main memory, transferring the value of the variable from main memory to the working memory of the thread, so that it can be used by subsequent load actions.
load(Load)
Acts on variables in the working memory and puts the variable value obtained from the main memory by the read operation into a copy of the variable in the working memory.
use(use)
Acts on variables in the working memory, passes the variable values in the working memory to the execution engine, and executes the byte code instruction when the virtual machine encounters a byte code instruction that needs to use the variable. operate.
assign(value)
Acts on variables in the working memory. The value received from the execution engine is assigned to the variable in the working memory. The virtual machine encounters the byte code instruction for the variable value. to perform this operation.
store(storage)
Acts on variables in the working memory, transferring the variable values in the working memory to the main memory, and then used by the write operation.
write(writing)
Acts on variables in main memory and puts the variable values obtained from the working memory by the store operation into the variables in main memory.
The basic data types of Java are divided into:
1. Integer type, used to represent the data type of integer.
2. Floating point type, a data type used to represent decimals.
3. Character type. The keyword of character type is "char".
4. Boolean type is the basic data type that represents logical values.
The above is the detailed content of Java memory interaction methods. For more information, please follow other related articles on the PHP Chinese website!