当前位置:网站首页>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 .
边栏推荐
- JS (III) convert ES6 syntax to Es5 syntax
- Player actual combat 25 unpacking module add close
- Redis data deletion policy in 2022
- Detailed explanation of C language memset
- Visual positioning guidance system for industrial manipulator (robot)
- Unhandled exception stack overflow
- Tu oses le croire? Il m'a fallu deux jours pour développer un système de gestion.
- Player actual combat 14 display YUV
- Communication flow analysis
- Interview (XI) futu written test questions
猜你喜欢

Mobileone: the mobile terminal only needs 1ms of high-performance backbone. You deserve it!

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

【OCR】AspriseOCR C# 英文、数字识别(中文不行)

Why do Chinese programmers change jobs?

webdriver入门

Getting started alicloud haas510 open board DTU (version 2.0) --510-as

selenium进阶

Markdown edit

Huawei equipment configuration BGP as number replacement

数据的收集
随机推荐
[wechat applet] 6.1 applet configuration file
Dataset and dataframe in sparksql
jenkins的RPC测试项目
[wechat applet] 4 Introduction to wechat developer tools
Detailed explanation of C language memset
Introduction to functions (inline functions and function overloading)
Player practice 11 audio resampling
QT database realizes page turning function
完美收官|详解 Go 分布式链路追踪实现原理
ADB command (I) record
我愿称之为史上最全的深度学习面经总结(附答案详解)
Unhandled exception stack overflow
Redis core configuration and advanced data types
Postgresql14 installation and use tutorial
Sorting out the differences between ABS () and Fabs () in C language
Player actual combat 25 unpacking module add close
QT realize picture dragging
C secret arts script Chapter 5 (structure) (Section 2)
Pay attention to click and pursue more users to enter the website. What bidding strategy can you choose?
Redis data deletion policy in 2022