How to execute functions in parallel with async.js?

前端 未结 4 1992
忘了有多久
忘了有多久 2020-12-12 07:03

In the following code, I have Array.forEach, It executes the doSomething synchronous function in sequence:

items.forEach(function(i         


        
4条回答
  •  萌比男神i
    2020-12-12 07:20

    Unfortunately Javascript is a single threaded language. However, HTML5 aims to improve this by adding Web Workers, which allows real OS-level threads to be spawned. If you are able to leverage HTML5 then this may work for you. You would be able to spawn a Web Worker for each item then wait until all threads are complete (joined).

提交回复
热议问题