Concurrency in Golang

Before diving into concurrency in Golang, I hope you have a basic idea about Golang as a programming language.

Many of you might have heard that Go has concurrency built into the language itself. This might open a question for a few that, other languages also support this, don’t they? [I’ll discuss this in detail later in the same article]

Before going into details of Go concurrency let’s take a look into what exactly is concurrency, and how it differs from the highly misinterpreted term parallelism.

Concurrency vs Parallelism:

What is concurrency?

Let me put it using real-world terms, when a person is carrying out two or more tasks simultaneously with some time/condition-based switching between tasks then those tasks can be called as concurrent tasks.

Now let me put it using a geeky example: Consider a hardcore programmer (whose brain doesn’t work without sufficient supply of caffeine in the blood), he needs to drink coffee while coding more often. Imagine when he is writing code with both of his hands, hitting the keyboard hard. And he remembers that he must take a sip or two from his mug, he stops writing code for a while and drinks his coffee and resumes the coding again. [Poor guy got only two hands :(]

What is parallelism?

Parallelism is the ability to carry out multiple tasks at the same time. It’s that simple.

Let’s consider an example: That same hardcore programmer also likes to listen to music while coding. In this case, he listens to the music at the same time when he is hitting the keyboard for writing code. [May be his brain has extra cores, one occupied in writing code one for listening music :)]

Concurrency in Golang:

Work in progress, please stay tuned :)

comments powered by Disqus