What is the difference between threading and parallelism?
Which one has advantage over the other?
If we think CPU as a company and threads as its workers then, it help us to understand threading and parallelism more easily.
Like a company have many workers, the CPU also have many threads.
Also there may be more than one company and therefore there may be more than one CPU's.
Therefore when workers(threads) work in a company(CPU), it is called threading.
And when two or more companies(CPU) work independently or together, it is called parallelism.
Threading is a poor man's parallelism.
EDIT: To be more precise:
Threading has nothing to do with parallelism and wise versa. Threading is about making feel that some processes run in parallel. However, this doesn't make processes to complete ALL their actions any faster in total.
Daniel Moth (a former coworker of mine)- Threading/Concurrency vs Parallelism article explains it all.
Quoted:
To take advantage of multiple cores from our software, ultimately threads have to be used. Because of this fact, some developers fall in the trap of equating multithreading to parallelism. That is not accurate...You can have multithreading on a single core machine, but you can only have parallelism on a multi core machine
The quick test: If on a single core machine you are using threads and it makes perfect sense for your scenario, then you are not "doing parallelism", you are just doing multithreading.
How do you define "parallelism"? Multithreading is a concrete implementation of the concept of parallel program execution.
The article RichardOD linked to seems to be mainly concerned with whether threads are actually executed in parallel on a concrete machine.
However, your question seems to see multithreading and parallelism as opposites. Do you perhaps mean programs that use multiple processes rather than multiple threads? If so, the differences are:
There are two different kinds of concurrency:
As you can see, they solve totally different kinds of problems.
Threading is a technology, parallelism is a paradigm that may be implemented using threading (but could just as easily be done using single threads on multiple processors)