- 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.
- Linux運維之道(第3版)
- Implementing Cisco UCS Solutions
- Linux Mint Essentials
- 曝光:Linux企業運維實戰
- Alfresco 4 Enterprise Content Management Implementation
- Windows Phone應用程序開發
- Learning Bootstrap
- Delphi Programming Projects
- Kali Linux高級滲透測試
- 新編電腦辦公(Windows 10+ Office 2013版)從入門到精通
- Hands-On GPU Programming with Python and CUDA
- Microsoft Hyper-V Cluster Design
- Linux深度攻略
- 計算機系統平臺
- 微信小程序項目開發實戰:用WePY、mpvue、Taro打造高效的小程序