Java Memory Model
Main memory and working memory:
The Java memory model stipulates that all variables are in main memory, and each thread has its own working memory.
The working memory stores a copy of the main memory used by the thread. All operations on variables by the thread must be performed in the working memory.
Interaction between memories:
1 lock acts on variables in main memory, which identifies a variable as a thread-exclusive state.
2 unlock Acts on variables in main memory, releases locked variables
3 read Acts on variables in working memory, transfers the value of a variable from main memory to the thread's working memory.
4 load acts on a variable in the working memory. It puts the variable value obtained from the main memory by the read operation into a copy of the variable in the working memory
5 use acts on a variable in the working memory and transfers the value of a variable in the working memory To the execution engine
6 assign acts on a variable in the working memory, assigns a value received from the execution engine to a variable in the working memory
7 store acts on a variable in the working memory, transfers the value of a variable in the working memory to in main memory.
8 write acts on variables in main memory, and puts the value of the variable obtained from the working memory by the store operation into the main memory
When a variable is defined as volatile, it will have two characteristics
1. Guarantee this variable Visibility to all threads is still not thread-safe for non-atomic operations.
2 Disable instruction reordering optimization.
Atomicity, Visibility and Orderliness
First-come-first-serve principle
State transition of Java threads
New New Create trailing edge and unstarted purebreds are in this state
Running Runnable includes operating system thread status Running and Ready in this state, the thread in this state may be executing, or it may be waiting for the CPU to allocate execution time to it
Waiting indefinitely Waiting Threads in this state will not be allocated CPU execution time, they have to Waiting to be explicitly awakened by other threads: Object.wait() method without setting Timeout parameter; Thread.join() method without setting Timeout parameter; LockSupport.park() method
Timed Waiting is in this state Threads will not be allocated CPU execution time, but there is no need to wait for other threads to be explicitly awakened. They will be automatically awakened by the system after a certain period of time: Thread.sleep() method; Object.wait() with the Timeout parameter set Method; Thread.join() method with Thimeout parameter set; LockSupport.parkNanos() method; LockSuport.parkUnitl() method
Blocked Waiting to acquire an exclusive lock
End Terminated The thread status of the terminated thread

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于结构化数据处理开源库SPL的相关问题,下面就一起来看一下java下理想的结构化数据处理类库,希望对大家有帮助。

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于PriorityQueue优先级队列的相关知识,Java集合框架中提供了PriorityQueue和PriorityBlockingQueue两种类型的优先级队列,PriorityQueue是线程不安全的,PriorityBlockingQueue是线程安全的,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于java锁的相关问题,包括了独占锁、悲观锁、乐观锁、共享锁等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于多线程的相关问题,包括了线程安装、线程加锁与线程不安全的原因、线程安全的标准类等等内容,希望对大家有帮助。

本篇文章给大家带来了关于Java的相关知识,其中主要介绍了关于关键字中this和super的相关问题,以及他们的一些区别,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于枚举的相关问题,包括了枚举的基本操作、集合类对枚举的支持等等内容,下面一起来看一下,希望对大家有帮助。

封装是一种信息隐藏技术,是指一种将抽象性函式接口的实现细节部分包装、隐藏起来的方法;封装可以被认为是一个保护屏障,防止指定类的代码和数据被外部类定义的代码随机访问。封装可以通过关键字private,protected和public实现。

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于设计模式的相关问题,主要将装饰器模式的相关内容,指在不改变现有对象结构的情况下,动态地给该对象增加一些职责的模式,希望对大家有帮助。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
