4 ms·
The key term to concurrency is the non-deterministic order of execution of multiple threads. Non-deterministic means that you run the program one time, the ord
by ww520 16y ago
The key term to concurrency is the non-deterministic order of execution of multiple threads. Non-deterministic means that you run the program one time, the order of execution is: thread 3, thread 5, thread 1, thread 4, and thread 2. You run it another time, the order can be: thread 1, thread 5, thread 2, thread 4, and thread 3. In another time with 2 CPU: thread 1/5, thread 1/3 (1 overlaps 5 and 3), thread 2, and thread 4. From your perspective, the OS schedules your threads "randomly." It might be due to system load, interrupt, or timing. Doesn't matter. It's just that the order is not guaranteed.
The goal of writing a proper concurrent program is no matter what the order of execution, the computed outcome is the same, due to consistency guarantee coded in.
- javert 16y agoThat's wrong because there's real-time systems out there that run threads in priority order. Are you saying that such a system does not have concurrency?