4 ms·
if you write harder concurrent program in JS, single threaded event loop does not help. It still has also same concurrency problems. e.g. if there is shared glo
by ashish_negi_ 4y ago
if you write harder concurrent program in JS, single threaded event loop does not help. It still has also same concurrency problems.
e.g. if there is shared global mutable state:
a) in workflow 1 you have, do_some_work_on_global_state; do some IO; in IO callback, finish more do_some_work_on_global_state.
b) in workflow 2 .. same like above work on global_state.
Now, in IO callback, you don't know if workflow 2 ran and have to handle all possible combinations of global_state above.
Replace global_state with common_state and problem still remains.
If you don't have common_state between multiple workflows, then it is not a hard concurrency problem and should be easy to do in all languages.
- moonchrome 4y agoSure it does, you don't have to manage on which thread you handle continuations (which you must in multithreaded GUI for example) - there's only one scheduler which simplifies the async API a lot. But even for concurrency - single threaded event loop/cooperative multitasking eliminates a whole class of partial state updates and synchronization primitive/locking errors - it's not even close to preemptive multitasking complexity.