- Mastering Concurrency in Python
- Quan Nguyen
- 154字
- 2021-06-10 19:24:06
The with statement in concurrent programming
Obviously, opening and closing external files does not resemble concurrency very much. However, we mentioned earlier that the with statement, as a context manager, is not only used to manage file descriptors, but most resources in general. And if you actually found managing lock objects from the threading.Lock() class similar to managing external files while going through Chapter 2, Amdahl's Law, then this is where the comparison between the two comes in handy.
As a refresher, locks are mechanisms in concurrent and parallel programming that are typically used to synchronize threads in a multithreaded application (that is, to prevent more than one thread from accessing the critical session simultaneously). However, as we will discuss again in Chapter 12, Starvation, locks are also a common source of deadlock, during which a thread acquires a lock but never releases it because of an unhandled occurrence, thereby stopping the entire program.
- Power Up Your PowToon Studio Project
- Ray分布式機器學習:利用Ray進行大模型的數據處理、訓練、推理和部署
- Apache Karaf Cookbook
- HTML5+CSS3網站設計基礎教程
- MongoDB權威指南(第3版)
- Learning R for Geospatial Analysis
- Create React App 2 Quick Start Guide
- Learning PHP 7
- The Professional ScrumMaster’s Handbook
- Java Web應用開發項目教程
- Node.js區塊鏈開發
- Oracle SOA Suite 12c Administrator's Guide
- Scala編程(第4版)
- Appcelerator Titanium Smartphone App Development Cookbook
- 打造流暢的Android App