3 ms·
That is parallelism, not concurrency. Concurrency: two functions can run one after the other while they are non blocking for the callers (e.g. hyperthreading).
by enoah_netzach 9y ago
That is parallelism, not concurrency.
Concurrency: two functions can run one after the other while they are non blocking for the callers (e.g. hyperthreading).
Parallelism: two functions can run at the same time (e.g. multiple processors).
- pizlonator 9y agoYour definition of concurrency is not correct. Concurrency usually implies that the work is chopped up into very small interleavable bits. A while function call with a loop of unbounded length being the default granule of interleaving is definitely not part of the definition of concurrency. The term "concurrency" subsumes both event loop style concurrency and two-cores-running-code-at-the-same time concurrency.
- Jtsummers 9y agoYes, it is. The JavaScript event loop is a very lazy scheduler than does no preemption. It's a very primitive concurrency model. It's up to the users of the language to break their tasks down into sufficiently small components or yield to allow for interleaving of work.