Search code examples
pythonmultithreadingconcurrencyparallel-processingpython-multithreading

'threading' library in Python | Concurrency or Parallelism?


I'm a noob at using threading library. I have been implementing from threading import Thread in conjunction with unittest and hypothesis libraries for test cases.

Concurrency vs. Parallelism is described concisely on this Medium article.

Which method of multi-tasking is threading?


Solution

  • Parallelism is a specialized form of concurrency, where multiple processors are executing the code simultaneously. Threads are how you introduce concurrency in the program. Not all language runtimes are capable of running these threads on multiple cores - because these runtimes may not be able to coordinate data access for these threads. So, in short, threads introduce concurrency, but whether they introduce parallelism depends on the runtime.