当前位置:网站首页>JUC concurrent knowledge points
JUC concurrent knowledge points
2022-07-29 06:17:00 【Plum juice】
Catalog
Understand concurrency and parallelism
wait and sleep The difference between
Lock and Synchronized difference
Condition Achieve accurate notification
What is? JUC:
JUC yes java.util.concurrent Abbreviation for package JUC refer to Java The concurrent toolkit for
Namely java.util tool kit 、 package 、 classification
Business : Normal thread code Thread
Runnable no return value Efficiency is compared to callable Relatively low
Lock lock
What is a process ?
: A collection of programs Implementation is a process
What is thread
A process contains multiple threads A process contains at least one thread
java There are several threads by default ? 2 individual One is main Threads One is GC Threads
java Can you really start the thread ? Can't open What is called is a local method At the bottom C++ Java Can't operate the hardware directly
Understand concurrency and parallelism
The nature of concurrent programming : make the best of cpu resources
Threads Several states
(new ) Freshmen (runnable) function ( bocked) Blocking (waiting) wait for (timed_waiting) Overtime waiting (terminated) End
wait and sleep The difference between


Lock lock
Fair lock You can come first and then
Not fair lock You can jump in line
Lock and Synchronized difference
1.Synchronized yes java Key words of Lock yes Java class
2. S Unable to determine lock status L It can be judged whether the lock is obtained
3 S Will automatically release the lock L The lock needs to be released manually Failure to release will result in deadlock
4 S Threads 1 Blocking 2 Will be waiting all the time L You don't have to wait
5 S Reentrant lock You can't interrupt Fair lock L yes Reentrant lock Unfair ( You can set )
6 S Is a small amount of code L Applicable to a large number of codes
What is a lock How to judge who the lock is ?
Producer consumer Two threads will not four 、 Multiple threads Will cause false awakening
Threads can wake up Without being informed False awakening Waiting should appear in the loop
if Judge only once False awakening will be caused when awakening
if Change it to while Judge
![]()

Condition Achieve accurate wake-up
Why should we wake up accurately lockA Thread processing finished There is no guarantee that B Threads need Condition To achieve precise awakening



边栏推荐
- Logistic regression - project practice - credit card detection task (Part 2)
- STM32FF030 替代国产单片机——DP32G030
- 封装——super关键字
- STM32 串口乱码
- EPS32+Platform+Arduino 跑马灯
- ABSA1: Attentional Encoder Network for Targeted Sentiment Classification
- 【软件工程之美 - 专栏笔记】24 | 技术债务:是继续修修补补凑合着用,还是推翻重来?
- SimpleFOC+PlatformIO踩坑之路
- JUC并发知识点
- arduino uno错误分析avrdude: stk500_recv(): programmer is not responding
猜你喜欢

【软件工程之美 - 专栏笔记】25 | 有哪些方法可以提高开发效率?

ArduinoIDE + STM32Link烧录调试

基于msp430f2491的proteus仿真

Hal library learning notes - 8 use of serial communication

兼容cc1101/cmt2300-DP4301 SUB-1G 无线收发芯片

Ml8 self study notes LDA principle formula derivation

扬尘噪声监控系统

Hal library learning notes-14 ADC and DAC

SimpleFOC+PlatformIO踩坑之路

新能源充电桩后台管理系统平台
随机推荐
Hal library learning notes-14 ADC and DAC
Pit avoidance: about the interconnection of two hc-05 master-slave integrated Bluetooth modules, there is no connection problem
爬取表情包
SimpleFOC调参3-PID参数整定攻略
基于msp430f2491的proteus仿真(实现流水灯)
Hal library learning notes-12 SPI
防爆倾角传感器应用于LNG液化天然气安全作业
电力电子:单项逆变器设计(MATLAB程序+AD原理图)
【软件工程之美 - 专栏笔记】21 | 架构设计:普通程序员也能实现复杂系统?
Huawei cloud 14 day Hongmeng device development -day3 kernel development
进程与进程的概念
【软件工程之美 - 专栏笔记】“一问一答”第2期 | 30个软件开发常见问题解决策略
Hal library learning notes-11 I2C
Pytorch's data reading mechanism
【软件工程之美 - 专栏笔记】28 | 软件工程师的核心竞争力是什么?(下)
兼容cc1101/cmt2300-DP4301 SUB-1G 无线收发芯片
八大排序-----------------堆排序
Ml4 self study notes
STM32: mcnamu wheel tracking task (library function program code)
基于wifi的温度采集与控制系统