> For the complete documentation index, see [llms.txt](https://note.levelcode.org/software-engineering-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://note.levelcode.org/software-engineering-notes/concurrency-vs-parallelism.md).

# Concurrency vs Parallelism

## Concurrency: dealing with multiple tasks at once

Example: trying to eat while having a conversation.

* It might be possible to do so, but you can't talk while chewing your food because you only have 1 mouth.
* Your mouth switch context so often between chewing and talking, you might think that you are doing both in parallel at the same time (but actually, no).
* In the context of software engineering, having 1 mouth in the example is the same as having only 1 thread.&#x20;
* Doing tasks asynchronously (with a single thread) will help us to achieve concurrency.

## Parallelism: doing multiple tasks at once

Example: eating while having a conversation, but you have 2 mouths.

* You have 2 mouths so you can eat and talk at the same time.
* If eating while having a conversation will make the it finish at 10 minutes, having 2 mouths will help you to finish it in 5 minutes.
* In the context of software engineering, having 2 mouths in the example is the same as having 2 threads with different cpu cores handling them.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://note.levelcode.org/software-engineering-notes/concurrency-vs-parallelism.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
