- 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.
- Getting Started with React
- Java系統分析與架構設計
- 基于差分進化的優化方法及應用
- Raspberry Pi 2 Server Essentials
- Python數據可視化之Matplotlib與Pyecharts實戰
- Mastering Predictive Analytics with Python
- Windows Forensics Cookbook
- C#程序設計
- 網站構建技術
- Python Data Analysis Cookbook
- 計算機應用基礎教程(Windows 7+Office 2010)
- Go語言編程
- Image Processing with ImageJ
- Serverless Web Applications with React and Firebase
- Solutions Architect's Handbook