Concurrency and Parallelism in Rust: An Overview and Examples

Sterling Cobb
2 min readDec 20, 2022

Concurrency and parallelism are important concepts in programming, and they are especially well-supported in Rust. In this article, we will explore what concurrency and parallelism are, how they differ, and how to use them in Rust.

What is concurrency?

Concurrency refers to the ability for different tasks or threads to make progress simultaneously. This is useful for handling multiple tasks at once, such as handling multiple incoming network connections or handling user input while performing background tasks.

What is parallelism?

Parallelism refers to the ability for different tasks or threads to be executed simultaneously on different cores or processors. This can greatly improve the performance of certain types of tasks, such as computation-heavy tasks that can be divided into smaller pieces and processed in parallel.

How do concurrency and parallelism differ?

Concurrency and parallelism are often used interchangeably, but they are not the same thing. Concurrency is about overlapping tasks, while parallelism is about executing tasks simultaneously on different cores or processors. Concurrency is useful for tasks that don’t need to be processed in parallel, while parallelism is useful for tasks that can be divided into smaller pieces and processed in parallel.

How do I use concurrency and parallelism in Rust?

--

--