Concurrency
Working with multiple threads (or processes) introduces concurrency: several things are happening “at once”.
How can I know the order in which operations will occur?
- physical concurrency
On a multiprocessor, thread executions may be arbitrarily interleaved at the granularity of individual instructions.
- logical concurrency
On a uniprocessor, thread executions may be interleaved as the system switches from one thread to another.
context switch (suspend/resume)
Warning: concurrency can cause your programs to behave unpredictably, e.g., crash and burn.