当前位置:网站首页>As a test, how to understand thread synchronization and asynchrony
As a test, how to understand thread synchronization and asynchrony
2022-07-25 20:53:00 【Software testing】
background
In daily tests , Program loading data file , Page jams often appear 、 Program not responding 、 Program crash, etc , The troubleshooting found that it is related to the synchronization and asynchrony of threads in the program process .
Case description
Problem description :
When opening a compressed file using the file viewer , There is a problem that the program is not responding .
Question why :
1、 After investigation, it was found that , When the file viewer opens the compressed file , It will traverse all resources in the compressed file , A resource parsing error occurred during traversal , Cause task blocking .
2、 After further understanding, it is found that , When developing functions , Put the resource traversal thread in the main thread for synchronous loading , So when the resource traversal thread is blocked , Cause the main thread to be unresponsive .
Solution :
1、 Add protection to the resource traversal thread blocking scenario , Ensure that the traversal thread executes normally ;
2、 Put the resource traversal compressed file thread from the main thread to the sub thread , Form asynchronous loading , Avoid a single thread failure that causes the main thread to hang up directly , Affect program use ;
It can be seen from the above cases that , Use synchronous or asynchronous threads in logical implementation , It is very important to improve the efficiency of the program and protect the main thread .
Extended thinking
1、 The development layer uses threads :
- Scenarios using threads :
① Move APP The program module needs to load the framework + Content time , Using threads is more efficient ;
② When optimizing program performance , Prefer to use threads ; - Application of thread synchronization and asynchrony in program :
① When the main thread executes a task , Execute asynchronous tasks in sub threads , The main thread does not need to wait for the result of the child thread to return , Complete the operation on the main thread , Wait for the result of the sub thread to return , Then call back to the main thread , Complete the whole process . This is the asynchronous loading operation of the thread , This can improve the efficiency of execution ( Here's the picture );
② The main thread is executing the task 1 when , Task waiting 1 After response , To start the task 2, Such as the task 1 Blocking , Then the whole process cannot proceed , Such synchronous threads have a great impact on the execution efficiency ( Here's the picture ).
2、 The impact of threads on testing :
1) The thread of case Design impact :
① The function of data stream loading class . Most of these functions are asynchronous threads , You can consider testing from the network level and loading level case The design of the ;
② JS Function of injection class . Such functions are mostly synchronous threads , You can inject JS Effectiveness of functions and JS Injection timing consider testing case The design of the .
2) The impact of threads on program performance :
① From the perspective of safety and performance , Synchronous thread solves the thread safety problem , But every time there is a judgment lock , Resulting in reduced performance ;
② Compared with synchronous threads , Asynchronous threads have a positive impact on program performance , More efficient , commonly APP Asynchronous threads are recommended in programs , Ensure the efficiency of the program .
Be careful : Between safety and performance , The first consideration is safety , The second is performance .
Conclusion
Understanding program implementation logic is essential in testing , Only understand in more detail and more clearly , In order to have a more comprehensive thinking about the test plan , So as to ensure product quality . Here, I hope you guys are more and more skilled , Go higher and higher on the road of software testing !
The house needs to be built layer by layer , Knowledge needs to be learned at one point one . We should lay a good foundation in the process of learning , More hands-on practice , Don't talk much , The last dry goods here ! I stayed up late to sort out the stages ( function 、 Interface 、 automation 、 performance 、 Test open ) Skills learning materials + Practical explanation , Very suitable for studying in private , It's much more efficient than self-study , Share with you .
Get off w/x/g/z/h: Software testing tips dao
Typing is not easy , If this article is helpful to you , Click a like, collect a hide and pay attention , Give the author an encouragement . It's also convenient for you to find it quickly next time .
边栏推荐
- Automated testing ----- selenium (I)
- [FAQ] access the HMS core push service, and the server sends messages. Cause analysis and solutions of common error codes
- [MCU] 51 MCU burning those things
- leetcode-6131:不可能得到的最短骰子序列
- Achieve accurate positioning based on Tencent map, and realize the attendance punch function of wechat applet
- Matlab---eeglab check EEG signal
- FanoutExchange交换机代码教程
- [tensorrt] dynamic batch reasoning
- Character function and string function (2)
- Basic knowledge of Marine Geology
猜你喜欢

Kubernetes进阶部分学习笔记

【网络教程】IPtables官方教程--学习笔记2

IEC61131 address representation

How to realize reliable transmission with UDP?

leetcode-6129:全 0 子数组的数目

Leetcode-155: minimum stack

preprocessor directives

leetcode-6125:相等行列对

Product principles of non-financial decentralized application

Chinese son-in-law OTA Ono became the first Asian president of the University of Michigan, with an annual salary of more than 6.5 million!
随机推荐
preprocessor directives
Pychart automatically enters the test mode when running the program
"Shallow in and shallow out" MySQL and InnoDB [it is recommended to collect and share]
476-82(322、64、2、46、62、114)
Behind every piece of information you collect, you can't live without TA
Leetcode-146: LRU cache
Online XML to JSON tool
PayPal PHP product trial period "recommended collection"
A detailed explanation of SCP command
一道golang中关于recover的面试题
Hello, I'd like to ask questions about C and database operation.
预处理指令
Leetcode-6126: designing a food scoring system
[matlab] download originality documents based on oil monkey script and MATLAB
Open source SPL enhances mangodb computing
How to obtain the subordinate / annotation information of KEGG channel
Interpretation of filter execution sequence source code in sprigboot
Miscellaneous notes -- a hodgepodge
Vulnhub | dc: 5 | [actual combat]
Volcanic engine Xiang Liang: machine learning and intelligent recommendation platform multi cloud deployment solution officially released