- 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.
- Advanced Machine Learning with Python
- Java Web開發學習手冊
- PyTorch自動駕駛視覺感知算法實戰
- SQL for Data Analytics
- MariaDB High Performance
- HTML5+CSS3網站設計基礎教程
- Python編程:從入門到實踐
- RabbitMQ Essentials
- C/C++程序員面試指南
- Python數據科學實踐指南
- Java設計模式深入研究
- Java EE 程序設計
- Mastering Vim
- Game Programming using Qt 5 Beginner's Guide
- Building an E-Commerce Application with MEAN