使用JavaScript Web Workers进行并行编程/同步 [英] Parallel programming / Synchronization using JavaScript Web Workers

查看:90
本文介绍了使用JavaScript Web Workers进行并行编程/同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何同步原语,例如障碍信号量锁定监视器,... JavaScript / Web Workers还是有一些库可以让我使用这些东西(我在想Java中的java.util.concurrent)?

Are there any synchronization primitives like Barriers, Semaphors, Locks, Monitors, ... available in JavaScript / Web Workers or is there some library available empowering me to make use of such things (I'm thinking of something like java.util.concurrent in Java)?

Worker是否具有模糊属性,使它们与Threads区别开来(例如,它们可以与主线程共享内存)吗?是否存在某种限制,可以产生多少工人(例如,出于安全原因或某些原因......)?我是否必须特别注意某些事情?

Do Workers have obscure properties which differentiate them from Threads (can they share memory with the main thread, for example)? Is there some kind of limit how many workers can be spawned (like, for security reasons or something...)? Do I have to take special care of something?

推荐答案

网络工作者没有共享内存的概念;将复制在线程之间传递的所有消息。话虽如此,您没有障碍,信号量,锁和监视器,因为您在Web工作者模型中不需要它们。

Web workers don't have a concept of shared memory; all messages that are passed between threads are copied. With that being said, you don't have Barriers, Semaphores, Locks, and Monitors, because you don't need them in the web worker model.

共享内存的概念是在2011年2月提出的,但由于开发人员的复杂性,现在状态为wontfix =>
https://lists.webkit.org/pipermail/webkit-unassigned/2011-February/287595.html

The concept of shared memory was proposed back in Feb 2011 but the status is now wontfix due to developer complexity => https://lists.webkit.org/pipermail/webkit-unassigned/2011-February/287595.html

此处还有关于网络工作者的精彩内容。
http://blogs.msdn.com/b/ie/archive/2011/07/01/web-workers-in-ie10-background-javascript-makes-web-apps-faster .aspx

There is also a nice blurb about web workers here. http://blogs.msdn.com/b/ie/archive/2011/07/01/web-workers-in-ie10-background-javascript-makes-web-apps-faster.aspx

希望这会有所帮助

这篇关于使用JavaScript Web Workers进行并行编程/同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆