What is concurrency?

Definition

Concurrent tasks may alternate on one processor or execute in parallel on several processors. The design must coordinate shared resources and define how results and failures move between tasks.

Overlapping work can improve responsiveness or resource use, but shared mutable state introduces risks such as races and deadlocks. Concurrency is not a guarantee of higher speed, and its controls must match the actual workload.

ELI5

Concurrency is handling several jobs in overlapping stages instead of finishing every job before starting the next.

For example, a server can wait for one request's data while processing another. If both tasks change the same record, it still needs a rule that prevents their changes from conflicting.

Is concurrency the same as parallel execution?

No. Concurrent tasks can overlap by taking turns on one processor, while parallel execution means tasks run simultaneously.

Does concurrency always improve speed?

No. Coordination, contention and task structure can reduce or eliminate the expected benefit.

  1. A simple flat interlocking code-bracket illustration with the blue and white headline Rust for AI Infrastructure on black.
Definition card for concurrency: What is concurrency?

Concurrency organizes multiple tasks whose execution can overlap, allowing a system to make progress on more than one activity during the same period.