当前位置:网站首页>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



边栏推荐
猜你喜欢

STM32 printf问题总结 semihosting microLIB理解

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

基于51单片机的直流电机调速系统(L298的使用)

【软件工程之美 - 专栏笔记】20 | 如何应对让人头疼的需求变更问题?

Dust and noise monitoring system

【RoboMaster】从零开始控制RM电机(2)-CAN通信原理及电调通信协议

智慧能源管理系统解决方案

LoRa开启物联网新时代-ASR6500S、ASR6501/6502、ASR6505、ASR6601

从头安装MYSQL(MYSQL安装文档-解压版)

充电桩充电技术新能源充电桩开发
随机推荐
arduino uno错误分析avrdude: stk500_recv(): programmer is not responding
From entry to soul: how to use tb6600 single chip microcomputer to control stepping motor with high precision (42/57)
DP1332E多协议高度集成非接触式读写芯片
【软件工程之美 - 专栏笔记】25 | 有哪些方法可以提高开发效率?
Hal library learning notes - 8 use of serial communication
无符号右移
2022 spring move - core technology FPGA development post pen test question (original question and experience)
Hal learning notes - Basic timer of 7 timer
Power electronics: single inverter design (matlab program +ad schematic diagram)
【软件工程之美 - 专栏笔记】16 | 怎样才能写好项目文档?
2.4G频段的无线收发芯片 SI24R1 问题汇总解答
TB6600+stm32F407测试
基于msp430f2491的proteus仿真(实现流水灯)
【软件工程之美 - 专栏笔记】14 | 项目管理工具:一切管理问题,都应思考能否通过工具解决
CV520国产替代Ci521 13.56MHz 非接触式读写器芯片
ML10 self study notes SVM
抽象类以及接口
QT learning notes QT model/view
FT232替代GP232RL USB-RS232转换器芯片国产化应用
shell工具finalShell