- 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.
- Redis入門指南(第3版)
- Java異步編程實戰(zhàn)
- 軟件測試項目實戰(zhàn)之性能測試篇
- 區(qū)塊鏈:以太坊DApp開發(fā)實戰(zhàn)
- Lua程序設(shè)計(第4版)
- 琢石成器:Windows環(huán)境下32位匯編語言程序設(shè)計
- Getting Started with NativeScript
- Hands-On Nuxt.js Web Development
- 新印象:解構(gòu)UI界面設(shè)計
- OpenCV with Python Blueprints
- Python青少年趣味編程
- 30天學(xué)通C#項目案例開發(fā)
- Leaflet.js Essentials
- Mobile Test Automation with Appium
- Splunk Developer's Guide(Second Edition)