3 ms·
No - concurrency is simple because the default state of running code is atomic. Variables CAN NOT change out from under you unless you explicitly place code in
by horsawlarway 5y ago
No - concurrency is simple because the default state of running code is atomic. Variables CAN NOT change out from under you unless you explicitly place code in a callback, or await it. This is utterly untrue in threaded code, where ANY line that is not explicitly guarded or explicitly an atomic operation, might have shared data change out from underneath it.
There are usually several events sources - just in a normal application
- Network calls
- Mouse actions
- Keyboard actions
- Timers
- awaits/promises/callbacks
- Service workers
- mutation observers
- postMessage events
- etc...
Are all viable sources of events. Some of them will trigger events incredibly often (ex - a handler registered to mouseMove or Scroll) - it has nothing to do with limited event sources, and everything to do with how the code executing the handlers is guaranteed to be atomic (unless it adds more events - such as a callback or an await)