Executing many instructions at once.
In a single computer, you can have parallelism with multi-core processors. Each core will execute instructions at the same time. With a single-core CPU, this is not possible!
With many computers, you can have parallelism by splitting a task into sub-tasks that can be performed independently, then sending each task to a different machine to execute.
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.
You can have parallelism without concurrency. You can have concurrency without parallelism. And you can have concurrency and parallelism.
async
/ await
in Node.js with its single-thread event loopthreading
module in CPython with its Global Interpreter Lockasyncio
module in CPython with its event loop and the Global Interpreter LockTODO: need a good (not so silly/trivial) example of this.
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.
go
) and channels (chan
) in the Go programming language.