Concurrency

A race condition occurs when two or more threads access shared data concurrently, and at least one of them modifies the data.

Alternatives include lock-free data structures, atomic operations, and higher-level abstractions like message passing.

Atomic operations are operations that are executed in a single, uninterruptible step.

Most instructions are not atomic. That means that context may switch during the instruction's execution.

A 'deadlock' is a scenario where all threads in the program wait for each other to release some resource (usually locks).

Concurrency: two queues and a single coffee machine.

Parallelism: two queues and two coffee machines.