- 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.
- LabVIEW Graphical Programming Cookbook
- R語言經典實例(原書第2版)
- Python 3網絡爬蟲實戰
- 人人都懂設計模式:從生活中領悟設計模式(Python實現)
- Rust Essentials(Second Edition)
- Jupyter數據科學實戰
- Learning Three.js:The JavaScript 3D Library for WebGL
- Visual C#.NET程序設計
- C語言程序設計教程
- C語言從入門到精通
- Python3.5從零開始學
- Raspberry Pi Robotic Projects(Third Edition)
- 大學計算機基礎實訓教程
- Applied Deep Learning with Python
- C/C++代碼調試的藝術(第2版)