- Mastering Concurrency in Python
- Quan Nguyen
- 215字
- 2021-06-10 19:24:03
The concept of thread synchronization
Before we jump into an actual Python example, let's explore the concept of synchronization in computer science. As you saw in previous chapters, sometimes, it is undesirable to have all portions of a program execute in a parallel manner. In fact, in most contemporary concurrent programs, there are sequential portions and concurrent portions of the code; furthermore, even inside of a concurrent portion, some form of coordination between different threads/processes is also required.
Thread/process synchronization is a concept in computer science that specifies various mechanisms to ensure that no more than one concurrent thread/process can process and execute a particular program portion at a time; this portion is known as the critical section, and we will discuss it in further detail when we consider common problems in concurrent programming in Chapter 12, Starvation, and Chapter 13, Race Conditions.
In a given program, when a thread is accessing/executing the critical section of the program, the other threads have to wait until that thread finishes executing. The typical goal of thread synchronization is to avoid any potential data discrepancies when multiple threads access their shared resources; allowing only one thread to execute the critical section of the program at a time guarantees that no data conflicts occur in multithreaded applications.
- Getting Started with Citrix XenApp? 7.6
- 基于粒計算模型的圖像處理
- JavaScript百煉成仙
- OpenNI Cookbook
- Building Mapping Applications with QGIS
- Easy Web Development with WaveMaker
- 移動界面(Web/App)Photoshop UI設計十全大補
- Visual Basic程序設計實踐教程
- Test-Driven Machine Learning
- Spring Security Essentials
- JavaScript應用開發實踐指南
- 跟戴銘學iOS編程:理順核心知識點
- Visual FoxPro程序設計習題及實驗指導
- 基于JavaScript的WebGIS開發
- 軟技能2:軟件開發者職業生涯指南