2 ms·
> Either your event handlers are going to be called in a nondeterministic order, or they won't. The order is not going to be completely deterministic, but your
by zzzcpan 11y ago
> Either your event handlers are going to be called in a nondeterministic order, or they won't.
The order is not going to be completely deterministic, but your whole program operates on explicitly deterministic units of computation that never implicitly execute in parallel (event handlers). This eliminates all of those issues with concurrent memory access.
Writing "synchronous" looking code cannot be a substitute, since it makes these units of computation implicit. After which it's no longer possible to distinguish which function call is going to yield, therefore dealing with concurrent memory access is going to be needed, just like in any multithreaded program.
So, no, event loops are superior to multithreaded model in almost every way.