当前位置:网站首页>Thinking: what is asynchrony and thread safety
Thinking: what is asynchrony and thread safety
2022-06-12 14:36:00 【Understand the principle + good code skills】
1) Asynchronously :
1. In a thread 1 Initiate a query request
2. Blocking threads 2 Wait for the result
3. Threads 2 Get the results , And put the results push To thread 1 Of the queue
...
If so : Threads 1 Launched 100 Requests , It can be seen that , What must be received is also returned in sequence .
2) Rethink synchronization :
Threads 1 launch func call, And get the result directly .
If so : Threads 1 Launched 100 Requests , It can be seen that , What must be received is also returned in sequence .
summary : So it seems , For the processing of a data , In fact, although it is asynchronous , But from the final call result , It's no different from a function call in a thread ! therefore , Do this ( Let a thread maintain the reading and writing of data all the time ), So it must be thread safe .
边栏推荐
- Player practice 18 xresample
- Perfect ending | detailed explanation of the implementation principle of go Distributed Link Tracking
- Player actual combat 22 to solve the problems of flower screen and Caton
- Two months' experience in C language
- win10_ Home Edition cannot use remote desktop, and can be accessed by remote desktop.
- 【OCR】AspriseOCR C# 英文、數字識別(中文不行)
- Jetpack架构组件学习(3)——Activity Results API使用
- Detailed explanation of factory pattern (simple factory pattern, factory method pattern, abstract factory pattern) Scala code demonstration
- New technology: efficient self-monitoring visual pre training, local occlusion no longer need to worry!
- G++ error in compiling Win32 program: undefined reference to '__ imp_ GetStockObject‘
猜你喜欢

What is automatic bidding? What are its advantages?

In C language, the main function calls another function, which is understood by assembly code

PMP agile knowledge points

How to use Android studio to create an Alibaba cloud Internet of things app

Unit test (I) unit test with JUnit

Location (I) error: command erred out with exit status
![[early knowledge of activities] list of recent activities of livevideostack](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[early knowledge of activities] list of recent activities of livevideostack

我愿称之为史上最全的深度学习面经总结(附答案详解)

The original Xiaoyuan personal blog project that has been around for a month is open source (the blog has basic functions, including background management)

Junit多线程的写法
随机推荐
用游戏来讲序列化与反序列化机制
[wechat applet] 2 Environmental preparation
Appnium (I) basic use of appnium
Analysis of two-dimensional array passing as function parameter (C language)
Webdriver opens in full screen and a prompt "Chrome is under the control of automatic test software" appears in Chrome
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Design of PLC intelligent slave station based on PROFIBUS DP protocol
Array one
你敢信?开发一个管理系统我只用了两天
QT link error: undefined reference to VTable for "XXX“
Can you believe it? It took me only two days to develop a management system
C语言中主函数调用另外一个函数,汇编代码理解
JMeter (V) pressure test of Excel file upload interface
Why do Chinese programmers change jobs?
Player actual combat 25 unpacking module add close
QA of some high frequency problems in oauth2 learning
Crawler problem set (I) record
selenium进阶
Player practice 11 audio resampling
Word insert picture blocked by text