- Distributed Computing with Go
- V.N. Nikhil Anurag
- 270字
- 2021-06-24 18:36:10
Concurrency
Let's look at the concept of concurrency using a simple example of a few daily routine tasks and the way we can perform them.
Imagine you start your day and need to get six things done:
- Make hotel reservation
- Book flight tickets
- Order a dress
- Pay credit card bills
- Write an email
- Listen to an audiobook
The order in which they are completed doesn't matter, and for some of the tasks, such as writing an email or listening to an audiobook, you need not complete them in a single sitting. Here is one possible way to complete the tasks:
- Order a dress.
- Write one-third of the email.
- Make hotel reservation.
- Listen to 10 minutes of audiobook.
- Pay credit card bills.
- Write another one-third of the email.
- Book flight tickets.
- Listen to another 20 minutes of audiobook.
- Complete writing the email.
- Continue listening to audiobook until you fall asleep.
In programming terms, we have executed the above tasks concurrently. We had a complete day and we chose particular tasks from our list of tasks and started to work on them. For certain tasks, we even decided to break them up into pieces and work on the pieces between other tasks.
We will eventually write a program which does all of the preceding steps concurrently, but let's take it one step at a time. Let's start by building a program that executes the tasks sequentially, and then modify it progressively until it is purely concurrent code and uses goroutines. The progression of the program will be in three steps:
- Serial task execution.
- Serial task execution with goroutines.
- Concurrent task execution.
- 發布!設計與部署穩定的分布式系統(第2版)
- 從零開始寫Linux內核:一書學透核心原理與實現
- Windows Phone應用程序開發
- 混沌工程:復雜系統韌性實現之道
- 深入Linux內核架構與底層原理(第2版)
- Moodle 3.x Teaching Techniques(Third Edition)
- Instant Optimizing Embedded Systems using Busybox
- Linux自動化運維:Shell與Ansible(微課版)
- AutoCAD 2014中文版從入門到精通
- 計算機系統的自主設計
- HTML5 Enterprise Application Development
- Java EE 7 Developer Handbook
- Getting Started with UDK
- BuddyPress Theme Development
- Serverless Architectures with Kubernetes