|
|
|
|
|
by extropy
4210 days ago
|
|
JavaScript does not share memory between threads. No shared memory - no need for sync code.
Instead it uses message passing and event loop to do the sync for you. The way it's implemented is similar to Windows 3.x times - collaborative multitasking.
Then there is no code to execute in your thread, an background event loop runs, listens for messages from another threads and calls appropriate callback function in your thread. This design has the benefit of being simple to do simple stuff. And near impossible for more complex multithreaded algorithms that require shared memory. |
|