When we search term concurrency in Golang, we come around mainly to the goroutines
and channels
. Sometimes we also find waitgroup
or mutex
.
There are many terms that can explain concurrency in Golang. But we mess it up when we start implementing the same.
Today we will discuss concurrency in Golang with an example of sentiment data processing using goroutines, channels, waitgroups, and many more terms.
Sentiment data processing: It is a data processing example, in which we can analyze sentiment data from social media posts, comments, or any expression-related data, whether the data is positive, neutral, or negative.
Concurrency in Go is one of the language’s key features and is designed to make it easy to write highly concurrent and scalable applications.
It is the ability to execute multiple tasks or processes simultaneously, that allows efficient use of system resources and improves application performance.
Concurrency vs parallelism with an example:
Note that concurrency and parallelism are two different terms.
Concurrency — It’s meant to do
multiple tasks
at thesame time
. It is a term used for writing programs.Parallelism —It’s meant to do
multiple tasks
withmultiple resources
at thesame time
. It is hardware related term, used when building CPUs and cores.
Example — Students have been assigned a task to write a paragraph from the board.
Concurrency: Students are reading from the board and writing at the same time. (one resource — student)
Parallelism: The teacher is reading loudly and students are writing at the same time. (multiple resources — student & teacher)
To understand all the terms with step by step guide and the sentiment data processing
example, check out our Canopas Blog.