@@Rishi_Khandelwal Although concurrency and parallelism are related concepts in terms of concurrent programming and can be used together, they aren't the same thing. Concurrency = multiple tasks that start/run/complete in overlapping time periods and in no specific order. vs. Parallelism = multiple tasks that run at the same time.
Great explanation. I would add a couple of remarks. You have to be aware that these terms may be used differently, people sometimes mixed them up. Or some use a different terminology. For instance, .NET uses the terms synchronous and asynchronous. I came across this definition of concurrency: concurrency means that two or more calculations happen within the same time frame. Meaning, several tasks run (with context switching) within a period of say 3 minutes. Managing multiple tasks simultaneously (within a time frame) is a good definition as well. IO-heavy and CPU-heavy is often referred to as IO-bound and CPU-bound. There is also the multitasking term, which is a more informal term that overlaps with both concurrent and parallel. Concurrency is an umbrella term for both concurrent and parallel execution. Parallel execution is a specific case of concurrency. But when they say the tasks runs concurrently, it means they run in interleaved, non-parallel way. This video is so good that I recommend to rewatch it any time a confusion arises.
This is wrong? Concurrency on multiple CPU cores enables parallel execution. Concurrency on a single CPU core requires switching. Parallelism is a subset of concurrency.
Absolutely. Yeah, people try to redefine words that already have a definition. Concurrent literally means at the same time. I will never understand the followers that just go with it without thinking "is he correct?"
When talking about multi-cores or multi-cpus for doing parallel tasks the most important thing to watch out for would the cpu/core cache coherency. It would've been nice to touch on that too. Keep up the good work though! Cool video.
Thank you very much for all the knowledgeable videos. We respect your efforts. Please make a video on system design of online coding judge, how leetcode or hacker rank handles the online contest's load.
So is it right when I say concurrency is better for multiple network call, like reading from a database, using concurrency, and based on each of the results returned, i can handle simultaneous computations using parallelism?
All we can do with a programming language ( such as C#, Java, python ) is to write a concurrent program. And when we run them on a machine, it may run parallelly or not. This is decided by the OS which decides it based on the hardware availability In these languages, we don't have much control to forcefully run tasks in truly parallel manner. These programming languages abstract away those details Is the above understanding right?
Yes, to my understanding, this is the case. If you let's say call Parallel.ForEach in C#, you give a hint to the OS that you would like to run it in parallel, if possible.
in the 2nd 'concurrent, not parallel', if task A and task B are running in sequence (one after the other) they can't finish at the same time. am i missing something?
your statement is correct. but you should see it more like this. a has 10 jobs, b has 10 jobs. If you do those alternate you end up done at roughly the same time (for a and b). Thats why the chef making 3 dishes is a good example.