- 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.
- 30天自制操作系統(tǒng)
- 混沌工程:復(fù)雜系統(tǒng)韌性實(shí)現(xiàn)之道
- Windows 7案例教程
- 一學(xué)就會:Windows Vista應(yīng)用完全自學(xué)手冊
- Distributed Computing with Go
- 大學(xué)計算機(jī)應(yīng)用基礎(chǔ)實(shí)踐教程(Windows 7+MS Office 2010)
- Multi-Cloud for Architects
- 應(yīng)急指揮信息系統(tǒng)設(shè)計
- VMware Horizon Mirage Essentials
- Android NDK Beginner's Guide
- 電腦辦公(Windows 7 + Office 2013)入門與提高
- Mastering Eclipse Plug-in Development
- Linux從入門到精通
- 嵌入式Linux設(shè)備驅(qū)動程序開發(fā)指南(原書第2版)
- VMware ESXi Cookbook