- Concurrent Patterns and Best Practices
- Atul S. Khot
- 353字
- 2021-07-16 17:32:26
Concurrency in a breeze
We start with a simple definition. When things happen at the same time, we say that things are happening concurrently. As far as this book is concerned, whenever parts of an executable program run at the same time, we are dealing with concurrent programming. We use the term parallel programming as a synonym for concurrent programming.
The world is full of concurrent occurrences. Let's look at a real-life example. Say that there are a certain number of cars driving on a multilane highway. In the same lane, though, cars need to follow other cars, the ones that are already ahead of them. A road lane, in this case, is a resource to be shared.
When a toll plaza is built, however, things change. Each car stops in its lane for a minute or two to pay the toll and collect a receipt. While the toll attendant is engaged with the car, other cars behind it need to queue up and wait. However, a toll plaza has more than one payment gate. There are attendants at each gate, attending to different cars at the same time. If there are three attendants, each serving one gate, then three cars could pay the toll at the same point in time; that is, they can get serviced in parallel, as shown in the following diagram:
Note that the cars queuing up at the same booth get serviced in sequence. At any given time, a toll attendant can service only one car, so others in the queue need to wait for their turn.
It would be really odd to see a toll booth with just one gate! People wouldn't be served in parallel. Strictly sequential processing of toll charges would make life unbearable for the frequent traveler.
Even when there are multiple gates and an abnormally large influx of cars (say on vacations), each gate becomes a bottleneck; there are far fewer resources for servicing the workload.
- UNIX操作系統(tǒng)設(shè)計
- vSphere Virtual Machine Management
- SOA實(shí)踐者說
- Mastering KVM Virtualization
- 構(gòu)建可擴(kuò)展分布式系統(tǒng):方法與實(shí)踐
- Windows Server 2012網(wǎng)絡(luò)操作系統(tǒng)企業(yè)應(yīng)用案例詳解
- Linux使用和管理指南:從云原生到可觀測性
- Kali Linux 2018:Windows Penetration Testing
- Windows 7應(yīng)用入門與技巧
- Linux服務(wù)器配置與管理
- VMware Horizon View Essentials
- AWS SysOps Cookbook
- Drupal 7 Cookbook
- OpenVZ Essentials
- Web Penetration Testing with Kali Linux(Third Edition)