``` Parallelism is simultaneous execution of tasks...
# announcements
m
Copy code
Parallelism is simultaneous execution of tasks, typically on different CPUs or machines. Concurrency, on the other hand, is the composition or interleaving of mul‐ tiple tasks. If a single CPU has multiple tasks (such as threads) on it, they are execut‐ ing concurrently but not in parallel by “time slicing.” Each thread gets a portion of CPU time before yielding to another thread, even if a thread has not yet finished.
Parallel execution is concurrent by definition, but concurrency is not necessarily par‐ allelism. In practice, this means being multithreaded is concurrency, but parallelism only occurs if those threads are being scheduled and executed on different CPUs at the exact same time. Thus, generically we speak about concurrency and being con‐ current, but parallelism is a specific form of concurrency.