Parallel programming / Synchronization using JavaScript Web Workers

前端 未结 3 1623
悲哀的现实
悲哀的现实 2021-01-18 18:11

Are there any synchronization primitives like Barriers, Semaphors, Locks, Monitors, ... available in JavaScript / Web Workers or is there

3条回答
  •  天命终不由人
    2021-01-18 18:29

    In short: no there aren't any synchronization primitives in javascript but there is also no need for them since JavaScript is inherently single threaded :). Workers can only access there own scope (no dom manipulation just calculations) and send messages to the main ui thread where the normal js resides. I'm not sure about the maximum count of workers but there sure is a limit, you could try it out in a browser :)

    Hope this helps!

提交回复
热议问题