Quantcast
Channel: Golang - Concurrency vs Parallelism vs Sequential - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Golang - Concurrency vs Parallelism vs Sequential

$
0
0

I am learning Go at the moment and got quite frustrated understanding the different between Concurrency vs Parallelism vs Sequential.

Let's say we have a process that scraps a slice of 5 URLs and paste the content in a text file. The process takes 2 seconds per URL.

  • Sequentially -> it takes 10 seconds since it does one after the other
  • Parallel -> takes less than 10 seconds since it does them simultaneously but using multiple threads or processors.
  • Concurrently -> takes less than 10 seconds but it does not require multiple threads or processors.

Not sure if I am right until here. My questions are:

I read that parallelism does things simultaneously (running and listening to music for example) and concurrency handles things at the same time (getting breakfast done while ironing shirts for example).

But if that's the case, why is concurrency not taking 10 seconds to complete since at the end of the day you are not doing everything at the same time but just doing bits of everything until you complete it all?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images