Concurrency and parallelism

Parallelism

Executing many instructions at once.

Examples

Concurrency

A way to structure programs to do many tasks at once.

The definition of task here is very important: By task we don't mean a program instruction, but rather a higher-level concept such as: sending an email, rendering an HTML page, playing an audio file.

So, another name for concurrency is multitasking.

Examples

Concurrency is not parallelism

You can have parallelism without concurrency. You can have concurrency without parallelism. And you can have concurrency and parallelism.

Examples of concurrency without parallelism

Examples of parallelism without concurrency

TODO: need a good (not so silly/trivial) example of this.

Examples of parallelism and concurrency

You actually need some effort to achieve this. Your program must be structured correctly for concurrency, and the programming language or whatever environment you're working in must support running concurrent tasks in parallel.

For example, in Go, just because you're using goroutines and channels doesn't mean your program is automatically concurrent and parallel, if you don't structure your program correctly to allow for that.